Protiviti / SharePoint Blog

SharePoint Blog

January 24
Nintex Workflow – Query a List in Another Site

Workflow Actions and Site Context

Many of the list and item-oriented actions in Nintex Workflow operate in the context of the site in which the workflow is running.  Because of this, referencing lists, items and documents in a different site from where the workflow is running can sometimes be a bit problematic.

At first glance, the Query List action seems to have this limitation.  In the screen shot below, notice the dropdown of lists.  They represent only the lists and libraries of the site where the workflow is being implemented.  What to do if a list from another site must be queried?



Using the CAML Editor

Fortunately, the Query List action includes two editing modes – Query builder and CAML editor.  While the Query builder is limited to the current site’s lists and libraries, the CAML editor is not.  In the next screen shot, observe the option to select an Alternative site.  Once selected, a Site URL area opens up.  You can then type in the alternate site, or better yet, use a workflow variable or workflow constant via the “browse” icon.




Wait minute.  Where did the dropdown list/library selector go?  It’s been replaced by a CAML query editing area.  CAML (Collaborative Application Markup Language) is the underlying syntax for all SharePoint list queries.  You say you are not a CAML expert?  Writing CAML queries is not high on your to-do list?

Get CAML the Easy Way

Fortunately, there is an easy way to have Nintex generate the CAML needed for your Query List action.  Here are the steps.  They assume that you are building a workflow in http://test/subsite1 and the list you want to query is in http://test/PTResources:

1.       While building your workflow in http://test/subsite1, switch the Query List action to CAML editor mode and Alternative site.

2.       Put a value into the Site URL area (I recommend a workflow constant to define the root level site followed by the sub-site).

3.       Leaving the workflow designer open to the Query List action as above, open another browser tab and navigate to the alternate site (http://test/PTResources).

4.       Navigate to the list you would like to query, and create a new Nintex workflow for that list.  Yep, that’s right.  Create a new temporary workflow for the target list.

5.       Add a Query List action to the temporary workflow.

6.       You will now be able to see the target list in the List dropdown.  Configure the query by selecting the list, setting the filter and configuring other options as desired in the first workflow (see screen shot as an example):






7.       Once the action is configured, switch the Editor mode from Query builder to CAML editor (remember, you are still working with the temporary workflow).  You will see your configuration transformed into CAML:




8.       Now that the CAML has been automatically generated for you, simply copy it from the temporary action, switch browser tabs to access the workflow in http://test/subsite1 and paste it into the first Query List action.  You will see the columns area populate with what you have configured:


9.       Finish configuring the action, and keep building the workflow.  When you have confirmed that the query works, delete the temporary workflow in the query target list.

Conclusion

Even though the use of CAML is required to query lists in another site (or site collection for that matter), using Nintex itself to generate the CAML is a good way to speed up the configuration of the Query List action.  Please note that this technique can be used in Nintex Workflow 2010 and 2013.  Not bad!!​

Quick Launch


© Protiviti 2020. All rights reserved.   |   Privacy Policy