Do you need to scan through a SharePoint Sites contents and apply some logic based on the existence of a content type? Or maybe even go as far as scheduling this? Then this post is for you!
**And the applicable SharePoint® version for the Nintex® Workflow versions above.
Greetings from a warm and sunny side of Johannesburg, South Africa! It's finally Spring time in this side of the world!
First things first, I would like to thank Michelle Barker for coming up with this question and requirement!
As you guys would know, reusable workflows have the following properties:
Some of the advantages of using a reusable workflow are:
Some of the disadvantages of reusable workflow:
What if then you were faced with a requirement that needs you to run a scheduled workflow based on a content type which could span across different lists and libraries? Maybe you have a requirement to send out reminder(s) at a certain frequency for certain document types?
How would you go about it?
Well there is a way that involves:
1. Finding all of your lists on your site
2. Getting all linked content types for each list
3. Per content type, Switch and apply your logic.
I built this using the following site workflow:
|Step #||Workflow Action||Description|
Call web service action (Get List Collection - Internal Names)
Note: I've configured this to actually return the InternalName of my lists or the GUIDs in a collection variable called ListCollection. You will see how and where we use this later...
Here I simply count how many lists are in my collection and store this in a variable called No Lists:
This is my first For Each where I basically loop through my ListCollection I retrieved in Step 1, and store the InternalName or the GUID of each list in a variable called ListGUID. The configuration is as follows:
Here I basically log the current lists index in my collection(ListCollection) as well as the ListGUID:
Call web service (Get List Content Types)
I then store the results in a collection variable called List Content Types. This step is configured as follows:
Note: The results returned here are in XML, and one of the NODES in the XML contain the Name of the content type, which is what we want
Seen that in Step 3.2 I get returned some XML, I simply query the XML in this step to get the Display Name of my content types and store these in a collection variable called Content Type Names. I've configured this step as follows:
This is my second For Each; which allows me to iterate through each content types name stored in my collection Content Type Names:
Here I simply log the name of my content type:
Switch (per content type)
Note that I haven't put this in my workflow, but this is where the magic happens for you guys.
So because we've found content types for any list or library across our site with the previous steps, we can use a conditional action such as a Switch to put in some workflow logic as required per content type!
Running this workflow will give you the following result in your workflow history:
So as you can see my Workflow scans the current site, and for each list and library returns the associated content types.
Feel free to download this and play around with it, and do what you will with it Maybe even make it a User Defined Action?
Let us know how you guys used this!
I hope this helps someone out there!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.