0

Good day!

I need a workflow that sends email to 20 list items and upon reaching 20, it sends a different email to the next item.

Don't even know where to begin, so would appreciate very much if you put me into the right direction.

Thank you.

Resty

1 Answers1

0

Is this SharePoint 2010 or 2013 Workflow?

If it is SharePoint 2013,

Use the below mentioned Rest API to get the count.

  • Call Http Event: WorkFlowContext:SiteURL/_api/web/lists/GetByTitle('ListName')/ItemCount
  • Save the output in the "ResultsDictionary"
  • And Get "d/ItemCount" from the "ResultsDictionary", store it in the Workflow local variable named "ListItemCount".
  • Put the condition
    If "ListItemCount greater than 20"
    Send Type2 email
    else
    send Type1 Email.

If it is SharePoint 2010,

Please visit the following URL:
How can I set up a workflow to count the number of items in a list?

Xavi
  • 153
  • 2
  • 12
  • Can I add another condition something like: If CurrentItem:Status equals Yes, so that it only counts this up until 20? – Resty Bautista Jun 14 '19 at 13:40
  • Yes you can depends upon the requirement. Based on the given query, i think we don't need "Status" column. – Xavi Jun 14 '19 at 14:17
  • thanks xavi. I'll give this a go and come back to you. – Resty Bautista Jun 17 '19 at 13:29
  • why do I get this error: {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The expression "web/lists/GetByTitle(DemoCountItems)/ItemCount" is not valid."}}} – Resty Bautista Jun 17 '19 at 15:01
  • Where did you get this error message? through the workflow or fiddler? – Xavi Jun 17 '19 at 16:27
  • workflow putting the variable ResultDictionary into an email. – Resty Bautista Jun 18 '19 at 07:36
  • xavi, I got the error sorted. forgot to put the apostrophes for list name. my problem now is how to count the item with the second condition. any idea? thank you. – Resty Bautista Jun 18 '19 at 13:57
  • Hi Resty, Have you stored the list item count to the local variable? then check the variable is equal to 20 using IF. Please let me know if you have any other second condition. – Xavi Jun 18 '19 at 15:09
  • hi xavi! it's actually another query to count items if movie was watched or not. I put in a choice column named watched. I need to count how many movies were watched. can you help? thanks. – Resty Bautista Jun 19 '19 at 10:08
  • Oh, Then build the rest query like this in your workflow. WorkFlowContext:SiteURL/_api/web/lists/GetByTitle('ListName')/Items?$Select=Id&$filter=(watched eq 'watched') . And then store this result to the dictionary and use "Count" event in the workflow to count the items in the resulted dictionary. – Xavi Jun 19 '19 at 16:33
  • Do I need to create another call web service condition to count movies I did not watched? Tnks. – Resty Bautista Jun 20 '19 at 13:27
  • xavi, pls chk this code. doesn't seem to work. WorkFlowContext:SiteURL/_api/web/lists/GetByTitle('ListName')/Items?$Select=Id&$filter=Watched – Resty Bautista Jun 20 '19 at 14:37
  • tried this as well.WorkFlowContext:SiteURL/_api/web/lists/GetByTitle('ListName')/Items?$Select=Watched&$filter=Watched eq 'Yes') – Resty Bautista Jun 20 '19 at 15:05
  • You told that "Watched" is a choice column, i think you're using it as "Booolean" column. For boolean you have to put filter condition like "filter=(Watched eq 1)". Here 1 for "Yes" and "0" for "No". – Xavi Jun 20 '19 at 18:12
  • you are a star xavi! it's perfectly working :)) – Resty Bautista Jun 21 '19 at 08:28
  • Thanks @RestyBautista. Sharing is Caring. – Xavi Jun 21 '19 at 20:53