The new “RenderForm” command
When qRules 4.3 was launched last
December 21, 2012 one of the newest commands was RenderForm. This command
generates an HTML rendering of one or more of the form’s views.
In other words it gives us the ability to output a rendered copy of the
form in a browser, by saving it as an HTML file, or it can provide us the
rendered form as HTML code that we can edit or save using a text editor, e.g.
Notepad, Notepad++, to later view it in a browser.
What are the parameters used in
RenderForm?
views(optional):
you can indicate which view to render, or render multiple views in one HTML file
by listing the views you want separated by ampersands (&).
allviews(optional): specify “true” for this value to render all of the form’s
views in a single HTML file
output(optional):
possible values are:
•
base64 which is the default and outputs the rendered HTML as a base64 InfoPath
attachment, which can be used in an attachment control
•
raw which outputs the rendered HTML as a string value
filename(optional): Allows specifying a filename for the output HTML file.
This is only applicable when using base64 output. The default value is
“rendered.htm”.
Some points to remember…
•
This
command requires the form to be full trust.
•
Do not
use both the /allviews and /views parameters at the same time.
•
This
command is not compatible with MOSS 2007 browser form but is compatible with
SharePoint 2010 browser forms.
•
View
names are case-sensitive.
• If specifying a filename, always include an
extension for the filename.
Here are an example I have created
for you…
The screenshots below are from a form I created with four simple views
to help us understand and also have a visual idea of how RenderForm works. By having this visual representation you can
see how different page layouts, colors, text, etc. will look in the browser.
I called the first view Render Command. I placed some of the possible combination of
commands we can use on a button control:
The second view is called PAL.
This is the third view and it’s named NBA.
The last view is called Sort.
We are going to use the Render
Form view to use some of the RenderForm commands…
The first button renders
all the views available on the form, and the command used is listed as the button's text. I used a rule to copy the value of the Result field of the
QdabraRules data source to a file attachment control right after the RenderForm command is
run. The filename that will appear in the file attachment control will
be rendered.htm since we did not specify any filename and because this is the
default filename. We can view the form in a browser by right-clicking the
file attachment then saving it or by opening it directly.
(all
four images below are displayed in a single browser tab)
The
second, third and fourth button renders only the view which is stated on the
label of the button, PAL view for the first button, Sort view for the second
button and NBA view for the third button. The filename will also be
rendered.htm for the three commands.
(all
three pictures below are viewed on separate tabs of the browser)
The fifth
button renders the PAL, Sort and NBA view only omitting the Render Form view
since it is not included in the command. The filename will also be
rendered.htm.
(images
are the same as the first button except the Render Form view is omitted)
The
sixth button renders the PAL view only but this time renames the filename to
PAL.htm instead of the default rendered.htm. We could also omit the
"/output=base64" since this is the default value for the command.
(this is
viewed from the preview of the Render Form after clicking the sixth button. The
rendered view is the same as the result of clicking the second button)
For the
seventh and eighth button we used a different output type called "raw". This will not
give us an htm file that we can directly view in a browser but gives us the HTML code. I used the text box to copy out the value of the Result field
of the QdabraRules data source. This value can be copied to a text editor where you
can edit and save it as an htm file to view it in a browser. We cannot specify a
filename because it would not be relevant here.
(this is
viewed while previewing of the form after clicking the
seventh button)