Solved

How to start a WF on a doclib view

  • 13 March 2024
  • 5 replies
  • 62 views

Badge +4

I’ve created a WF on a doclib for docs that are finalized/ready for the process flow of the wf.    For it to go into production, the WF needs to be started (manually, or better yet - scheduled) on a specific view, to run on all docs in this view. How do I configure the wf to start on a certain view? 

Does it need to be a site wf?  If so, same question, how do I configure it to run on all docs in the view?  (these docs have the same CT, but there are other docs in the same doclib with the same CT that need a different process flow/different wf). 

icon

Best answer by BobR 26 March 2024, 09:58

View original

5 replies

Userlevel 1
Badge +6

Views in Sharepoint, whether it is for lists, document libraries, or calendars, are nothing more than layout changes. They filter the underlying data so the user gets to see a subset of the data sorted and arranged in a certain way depending on the view settings. This is separate from Nintex Workflow that just sees the entire list content (read list as list, library, or calendar here, libraries are just lists of files and calendars are just lists of events).

What I am assuming you want is to have your workflow to only run on a certain subset of the files on the document library. The view filters based on the metadata to only show the user the files you want to run the workflow on. You can probably achieve this best through the List Query action in a workflow (this works in either list workflows or site workflows). In the List Query action you can look through the document library and use the Filter to only pull out the files you want to perform the workflow on, by using the same criteria as the filter criteria in your view. Let the List Query output the ID of the files to a collection variable, and then use a For Each action to loop through each of the files to perform whatever workflow actions you need to perform on these files, you can find them by matching the ID.

Badge +4

Thank you - I configured the WF to kick off on Condition that match the VIEW's configuration filter, BUT I am currently recreating this WF as a site WF in order to schedule it.  I learned about the control: Query List in order to set all metadata from the doclib, then recreated a few other variables. 

How do I configure the WF to then take the PDF to a final destination doclib?  I’m unfamiliar with Site WF’s. 

Userlevel 1
Badge +6

Site workflows work almost exactly the same as list workflows. The only real difference is that they don’t have a current item or list they run on. To copy the file from one library to another you can use a Copy Item action.

Basically, you do something like this

  1. List Query. Collect the IDs of all files to be copied from Library A and store them in a collection variable
  2. For Each. Use the collection variable to run the next actions for each file. You store the current ID in a separate variable (a single line of text variable should be fine)
  3. Copy item. Copy From Library A, where ID equals the current ID variable (find it under workflow data), and select your destination library from the list under “Copy to”. Make sure the Copy item action is inside the For Each group.

This should work. Make sure that the columns or content types match between the two libraries so the metadata gets brought along. If you don’t want to retain the file in Library A, you can put a “Delete item” action inside the For Each group after Copy item. Select again Library A and match the ID just like for Copy item.

Badge +4

Thank you.  The final destination doclib is in a different site collection, so the list of choices does not contain the one needed.  I have configured BuildString with the URL for the final destination - storing in a variable.

In another solution, I’ve saved URLs in a variable, but here (in this COPY ITEM control) that isn’t an option. 

Userlevel 1
Badge +6

If the destination library is on a different site, you need to use the Copy to Sharepoint action instead of the Copy item action.

Copy to Sharepoint only works on a current item that the workflow is running on, so it can’t be called directly from a site workflow. To get around this, in your site workflow you can start a list workflow on the item to be copied, and let that list workflow copy the item to the destination library. You can use a Web service query in the site workflow to start the list workflow.

For the Web service query, you need to enter a URL where the server can find the web service, this will typically be the site with the library from which to depart, followed by /_vti_bin/NintexWorkflow/Workflow.asmx

For Webmethod you select the StartWorkflowOnListItem method (click Renew after entering the URL to enable the dropdown). For itemId you use the ID you are matching with, listName is just the name of the document Library where the file is found, and workflowName is the name of the list workflow that has the Copy to Sharepoint action.

That list workflow should be attached to the document library from which the file departs, and it can just have the Copy to Sharepoint action and nothing else (or maybe a build string to build the destination url, the url should direct to the destination library), disable manual or automatic starts so it only starts through the webservice query.

To summarize, you put the Webservice query in your Site workflow, within the For Each action group. The webservice calls the list workflow on the library, and that list workflow will copy your item to the destination library.

Make sure that the account credentials you use for the Web Service query have writing permissions on the destination library as well, otherwise Nintex won’t be able to copy the file and the workflow will error.

Reply