How to iterate a qRules command - Ernesto Machado
in

InfoPath Dev

Ernesto Machado

How to iterate a qRules command

This technique comes from one of Qdabra’s own customers, John Shaw, who is a qRules user. This cool idea will iterate the SaveToSharePoint command for multiple file attachments. This tutorial builds on the example show in a previous document by making the command repeating.

1.    Create a new, blank form and inject it with qRules. For information on how to do this, please refer to the qRules User Guide.

2.    Create the following initial schema, where DetachFile is a Boolean attribute, which defaults to false. For information on the qRulesLink and qRulesFilename, see the qRules User Guide.

 

3.    Set a text box (AttachmentName) in the repeating section. This field allows the user to name the attachment being uploaded.

 

4.    On the Boolean DetachFile node, create a rule that set the command node in the QdabraRules secondary data source to the command SaveToSharePoint. This rule will only execute when DetachFile is equal to true. The command will look like this:

concat("SaveToSharePoint /url=<YOUR_LIBRARY_URL> /xpath= /my:myFields/my:ContainerGroup/my:RepeaterGroup/my:Attachment /name=", AttachmentName, " /overwrite=no")

[It makes a difference if the command has "/overwrite=no". If it is set to YES, it will only ever use the first occurrence of the /name parameter. When it is set to NO, each item in the repeating table is given its correct, corresponding name.]

5.    Add a second action to reset DetachFile back to false.

 

6.    Design the form to show the repeating section. The exact design is up to you, but the screenshot below shows an example:

 

7.    Add a button to the form and label it “Upload attachments”. This button will use rules, and its only action is to set the Boolean attribute of the attachment field to true.

 

Now when a user attaches more than one attachment and provides a filename for each attachment, clicking the button will iterate thru each attachment to upload it to SharePoint.

Comments

 

Scott Rooke said:

This is great but is there away to use the SaveToSharePoint command to save to multiple document libraries?  Essentially have two attachment fields on the form?

I've tried and IP complains that there are duplicate fields it relates to the Qdabra fields.  Thoughts?

November 2, 2011 11:50 AM
Copyright © 2003-2012 Qdabra Software. All rights reserved.
View our Terms of Use.