0

I have setup three columns, one number, two calculated. Seq (number), NextNum(calculated Seq+1), SerNum(calculated conat"text"&000&NextNum

What I am trying to do in sharepoint with a workflow or any other suggestion is to set the seq to the next in a seq based on SerNum as it will start with 0 in seq but use the Max NextNum for seq when a new item is entered but a different type EX: (I am using submit to start WF in the infopath form)

Type      Seq                  NextNum                 SerNum
999        0                    =B2+1     =CONCATENATE(A2,"_","000",C2)
999      =IF(A3=A2,B2+1,0)      =B3+1      =CONCATENATE(A3,"_","000",C3)
999      =IF(A4=A3,B3+1,0)      =B4+1      =CONCATENATE(A4,"_","000",C4)
777      =IF(A5=A4,B4+1,0)      =B5+1      =CONCATENATE(A5,"_","000",C5)
777      =IF(A6=A5,B5+1,0)      =B6+1      =CONCATENATE(A6,"_","000",C6)
777      =IF(A7=A6,B6+1,0)      =B7+1      =CONCATENATE(A7,"_","000",C7)
777      =IF(A8=A7,B7+1,0)      =B8+1      =CONCATENATE(A8,"_","000",C8)
888      =IF(A9=A8,B8+1,0)      =B9+1      =CONCATENATE(A9,"_","000",C9)
888      =IF(A10=A9,B9+1,0)      =B10+1      =CONCATENATE(A10,"_","000",C10)
999      =IF(A11=A10,B10+1,0)      =B11+1      =CONCATENATE(A11,"_","000",C11)

with results:

Type      Seq      NextNum      SerNum
999                  0             1             999_0001
999                  1             2             999_0002
999                  2             3             999_0003
777                  0             1             777_0001
777                  1             2             777_0002
777                  2             3             777_0003
777                  3             4             777_0004
888                  0             1             888_0001

Any assistance would be greatly appreciated

1 Answer 1

1

This can be done with a SharePoint 2013 workflow. The workflow would make a REST API call to get the items. It would include a "$filter=" to select the "Type" items ("777"), an "$orderby=" to get the largest numbered it first, and "$top=" to get just the one item.

Something like this:

http://yourServer/sites/yourSite/_api/web/Lists/getbytitle('yourListName')/items?$select=Id,Title,Seq&$filter= Title eq 777&$orderby=Id desc&$top=1

The $select only needs "Id", but the others are useful for testing.

You can type this URL (with your site and list data) into your browser to see the returned data.

The workflow would:

  1. Build a dictionary object for the HTTP request header.
  2. Make the REST call.
  3. Count the items in the returned dictionary.
  4. If no items returned, set the Seq of the current item to 1 and exit.
  5. Get the value of the Seq from the REST call and add one.
  6. Set the Seq for the current item to this new value.
  7. Configure the workflow to only update on Create only.

Here's the workflow. (There's lots of hidden details, but it gives you and idea of what's involved.)

enter image description here

Here's the result:

enter image description here

5
  • can it be done with 2010? I have SPD 2013 on 2010 Workflow Commented Jan 14, 2018 at 15:46
  • No, the REST web service call action is only available in the 2013 style workflows. Is the 2013 style workflow not available in your SharePoint Designer? If you are not using SharePoint 2013 Foundation, your SP admin can install the 2013 workflow services. 2013 style workflows are not supported in Foundation. Commented Jan 14, 2018 at 17:58
  • is there an alternative method as I have checked and we won't begetting Workflow 2013. Maybe a workflow to set current count plus one for next number to create the new ID for like items? Commented Jan 15, 2018 at 15:58
  • You could add JavaScript to the New form that could make the REST call to get the next number in that category, but that would not help if the user used the Quick Edit view to add new items. You could create a separate list that had an entry for each category, 777,888,999, etc., with a "Last Seq Number" column. The list's workflow could find that category's entry and update the Seq number. Commented Jan 15, 2018 at 18:42
  • I would prefer to do this your suggested way but am limited. I did figure out a way using by your suggestions(for 2013) but doing it (in 2010). I created a list (used as the build library) and a rule in the form as well as a workflow. It works perfectly. I thank you for the help because I was able to compare it to what I had and go from there. Commented Jan 16, 2018 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.