2

This one has stumped me indefinitely... so I'm coming to the great guru's of the confusing concepts.

CASE:

I have an InfoPath form which is connected to a document library. Once the form is submitted, it will create a new form (like usual), and on create it initiates a WorkFlow which will turn into a huge complicated spaghetti bowl. However, the only thing I want is to increment an ID number of sorts (We'll call it f-number). It must be formatted with three digits (E.g. 042, 120, 002, etc.).

So, the steps:

  1. The f-number must be incremented from the previous item
  2. Formatted as a three-digit number
  3. Automatically populated inside the current item

ATTEMPTS:

I have created two columns inside the document library; the first is the calculated value of f-number + 1 (calc-f-number). The second is the formatted text (Using the TEXT([COLUMN], "000")) as three-digits(formatted-f-number). Then I created a separate custom list called AutoID with a column called prev-id-number. Inside is a single item with the ID number of the previous item. During the workflow, it is SUPPOSED to: (This is formatted like the WorkFlow for ease of translation)

  • Set f-number inside Current Item based on:
    • formatted-f-number column inside Document Library, by the Document Library ID equal to:
      • the prev-id-number inside AutoID custom list that has ID equal to 1

Then set the AutoID to the ID of the Current Item.

For some reason, when I try to select prev-id-number, it will only let me select ID, UI Version, URL Path, Item Type, Level and Path. Perhaps there is a MUCH MUCH simpler way to do this, but through the tiny bit of information research churned up this seemed like the only course of action.

QUESTION:

First and foremost, is there an easier way to do this?

Or how can I select prev-id-number? Could it be based on actual column TYPES? If so, why does WorkFlow only allow you to select certain column types?

2
  • what column type is prev-id-number? lookup or text?
    – Zork
    Commented Mar 27, 2012 at 12:47
  • prev-id-nmber is a text field. Commented Mar 29, 2012 at 4:55

3 Answers 3

1

Christopher,

You can do the auto-increment in the InfoPath form during submission. Create a data source to the list that the form is published to and only lookup your incrementing column (f-column) and query at form load. Then during submission, set a field (f-field promoted to f-column) with the following rules:

Rule 1:

  • Condition

    1 + number(xdMath:Max(xdxDocument:GetDOM("[data source]")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:F-Column)) > 0

    AND

    F-Field does not match pattern Custom Pattern: 0

  • Actions

    F-Field =

    1 + number(max(F-Column))

Rule 2:

  • Condition

    F-Field is blank

  • Actions

    F-Field =

    number(1)

I am unsure of how the formatting should be set up. The problem is that f-column needs to be set up as a number column and I'm fairly certain that any number you put in there will only display significant numbers (no leading 0's). If I find more information on the formatting side of this issue, I will update my post.

0

Could you just use the workflow to match the ID without using the calculated column.

In the workflow do something like

  1. Get previous item (SharePoint) id number by doing performing a calculation action of "Calculate 'CurrentItem:ID' minus 1 (Output to Variable:PrevID)
  2. The create new DocID "Calculate 'Get Source - This is a defined lookup, look at the same list choose the DocID for the item and then in Find the List Item choose the Item ID and match the value to PrevID determined in Step one, this will get you the previous DocID' plus 1 (Output to Variable:NewDocID)
  3. Set DocID to Variable:NewDocID

I wish I had more time to detail this out some more, but let me know if this makes sense.

2
  • there's no guarantee CurrentItem:ID - 1 will actually exist though, and that will error out if it doesnt.
    – Zork
    Commented Mar 27, 2012 at 12:42
  • The final output that I need isn't identical to the ID - for example if someone deletes a file, the increment cannot skip numbers. That's why I was using the ID + Calculated field to reference the previous field. Commented Mar 29, 2012 at 4:57
0

I would need to think more for a better solution, but a way to get it to work...

Create a separate list and the only thing in it is Title set to 1, and a lastID column that gets continuously updated to the most recently added value.

All you have to do is search through that separate list where Title = 1, and you will have the previous ID. And of course every time you get the previous ID, you update it.

4
  • I did precisely that, and it works up to 4 rotations then breaks. The fiels start populating with things like "error#1" or "float;#2.00000000000". Definitely seems like column types, right? Commented Mar 29, 2012 at 4:59
  • huh, glad to see we are at least on the same page! yes it seems that way.. I'll think on it a bit and see if i can come up with something. Update: Unfortunately I cant think of a different solution save either coding a workflow as a whole, or using an Item Adding Event Receiver. With code you have a lot more flexibility, and the ability to debug odd issues like that you've mentioned. I'm not sure how to go about that in a regular workflow...
    – Zork
    Commented Mar 29, 2012 at 13:06
  • Do you know a good IDE for making workflows? Commented Mar 30, 2012 at 4:11
  • Visual studio 2010 is by far the best way to develop for SharePoint, it has prebuilt templates that handle all of the backend functionality. Watch a tutorial or two and you would be good to go. According to this link: erikasblog.datainspirations.com/2010/10/07/… you could also use VS2008 without too much trouble as well
    – Zork
    Commented Mar 30, 2012 at 12:43

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.