Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > "Printable" Form using Alternate BizForm View modes: 
User avatar
Member
Member
ctaleck IPAGlobal - 2/9/2010 2:37:40 PM
   
"Printable" Form using Alternate BizForm
I would like to create a printable form. So I have created an alternate BizForm and changed all fields to use the Label control (instead of Textbox, etc.). I added the BizFrom Webpart to my Design and specified the "Alternative form name"

Now I am uncertain how to do the next step. How do I get the page to show my data?

My first guess is to load in data into the new page using a query string parameter. But specifying the ID for the table does not do that. I'm guessing I'm might have to do some customizing of the Webpart if this this is not already a built-in feature.

User avatar
Member
Member
ctaleck IPAGlobal - 2/9/2010 3:06:11 PM
   
RE:"Printable" Form using Alternate BizForm
I was wondering if I could do something similar to the "pencil" icon in the CMSDesk? This seems to call a "EditRecord(1,9)" command so I'm not sure how that mechanism is working...

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/10/2010 3:44:06 AM
   
RE:"Printable" Form using Alternate BizForm
Hello,

I've prepared knowledge base article with whole procedure. Could you please check it: How to display data of BizForm for print

Best Regards,

Martin Dobsicek

User avatar
Member
Member
ctaleck IPAGlobal - 2/10/2010 3:22:51 PM
   
RE:"Printable" Form using Alternate BizForm
Thanks. For some reason that article did not appear in my search.

Will that KB article code work for Kentico 4.0? (It is marked as applying to 5.0.) I have not upgraded yet.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/11/2010 7:30:41 AM
   
RE:"Printable" Form using Alternate BizForm
Hello,

Actually I've added this article yesterday as reaction to your forum post :). I think some other visitors may find it useful in the future too.

I haven't tested this procedure in version 4.0 but I think it should work in this version too. Nevertheless, if you encounter any issue please feel free to ask.

Best Regards,

Martin Dobsicek

User avatar
Member
Member
ctaleck IPAGlobal - 2/11/2010 4:22:39 PM
   
RE:"Printable" Form using Alternate BizForm
The solution work in v4.0.

Here is an improvement to avoid errors when the recordID is invalid. I hope this is the best way to test this as I retrieved it from the documentation.

    protected bool RecordExists(int formRecordID)
{
string bizFormName = this.BizFormName;
string siteName = this.SiteName;
bool Result = false;

// Get BizForm definition
BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormName, siteName);

if (bfi != null)
{
// Get data type definition
DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
if (dci != null)
{
// Get all bizform data
GeneralConnection genConn = ConnectionHelper.GetConnection();
DataSet ds = genConn.ExecuteQuery(dci.ClassName + ".selectall", null, null, null);

if (!DataHelper.DataSourceIsEmpty(ds))
{
// Get the record with specified ID
DataClass formRecord = new DataClass(dci.ClassName, formRecordID, genConn);

if (!formRecord.IsEmpty())

Result = true;

}

}
}
return Result;
}

Therefore, I test RecordExists(formRecordID) instead of formRecordID > 0.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/17/2010 6:24:52 AM
   
RE:"Printable" Form using Alternate BizForm
Hello,

You're right. I haven't realized the error is thrown if ID of non-existing record is specified. Your code is correct, just the ExecuteQuery method is not necessary as you already have ID of record. I've updated the KB article with slightly modifed RecordExists function - I have also changed 'if' condition in SetupControl() method so the RecordExists method is not call when recordId is 0 (to avoid unnecessary SQL calls in RecordExists function as it always return false when recordId is 0 anyway). Thank you for your co-operation!

Best Regards,

Martin Dobsicek

User avatar
Member
Member
ctaleck IPAGlobal - 2/15/2010 10:07:52 AM
   
RE:"Printable" Form using Alternate BizForm
I would like to list out all my BizForm entries using a repeater showing the print link I created above. But I do not see the table data exposed in any of the Web Parts. Is there one or do I need to customize this also?

i.e.

Print 1 Bizform Entry One (links to http://mysite/formprint?id=1)
Print 2 Bizform Entry Two (links to http://mysite/formprint?id=2)
Print 3 Bizform Entry Three (links to http://mysite/formprint?id=3)

etc.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/17/2010 6:30:02 AM
   
RE:"Printable" Form using Alternate BizForm
Hello,

You can write custom query that will get data from BizForm's table (simple select query should be sufficient) and then use QueryRepeater web part with your query and appropriate transformation that will generate links. You can get ID of record using standard Eval("nameOfFieldWithID") method in transformation.

Best Regards,

Martin Dobsicek

User avatar
Member
Member
ctaleck IPAGlobal - 2/17/2010 10:50:08 AM
   
RE:"Printable" Form using Alternate BizForm
Just to make this clearer and to make sure I'm doing best-practice, this is what I did.

Under Site Manager > Document Types > Edit Root > Queries Tab, I added the following:
SELECT ##TOPN## * FROM BizFormTable WHERE ##WHERE## ORDER BY ##ORDERBY##;
Also under the Transformations Tab, I added the following:
<tr>
<td><a href=/PrintPage?id=<%# Eval("ID") %> target=_blank>Print</a></td>
<td><%# Eval("ID") %></td>
<td><%# Eval("Title") %></td>
</tr>
Then I added a WebPart under Listing and viewers > Repeater with custom query (queryrepeater) and specified the above query and transformation.

Under HTML Envelope, I also added this HTML:
Content before: <table width=100%><tbody>
Content after: </tbody></table>
I hope this helps out those who like it step-by-step.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/3/2010 3:17:35 AM
   
RE:"Printable" Form using Alternate BizForm
Hello,

Yes, I think this is the best-practice. Thank you for your detailed step-by-step description.

Best Regards,

Martin Dobsicek