I created an IT Help Desk ticketing system and now I would like to add automatic numbers with characters i.e. KM111 or IT222 . I followed the below but for some reason my numbers come out with like… KM’error’&222
Customer Requirement: A unique ID was needed for each item in a list upon item creation. The ID needed to start with the number 6000, increase by 1, and concatenate the number with the first three characters of a location code.
SharePoint Option: Out of the box, SharePoint has an auto-generated field called ID that starts at 1 and increases by 1 with each new entry. If you delete an item in a list, that ID is removed from the list as well so there is no chance of having a duplicate ID. One issue we ran into is you cannot use ID in a calculated field for new items. It will work fine for existing items but, the ID is not assigned to a new item until the user hits submit. So the calculated column that uses ID will get a value of 0 on all new items and does not change the calculated column even if you refresh or edit the item. You actually have to edit the calculated column and all existing items will be correctly calculated.
Final Solution: We wrote a SharePoint Designer workflow that will add the ID to the number 6000 and concatenate the number with the first 3 letters of the Campus Code.
How we did it: In our list, we created the following columns required for the workflow. (Several other columns exist in the list to collect additional information but, these were needed for the workflow solution.) We used a content type to hide the fields that are used by the workflow from the user forms.
- “SPID #” – Single Line of Text – hidden field
- “Campus” – Choice field with the names of the 5 campus choices prefixed by the campus code (ex: UCH – University of Colorado Hospital)
- “CTRCCode” – Calculated Column (Formula: =LEFT[CTRC Campus],3)) – hidden field
Once the list was set up, we opened the site in SharePoint Designer
- Select File – New – SharePoint Content – Workflow – Blank Workflow – OK.
- Give a name to the workflow – we used “Generate SPID”
- Attach the workflow to the list
- Select the start options – we selected manual and on item creation
- Click Next
1. Provide a name for the first step of the workflow if you like – we used “GenSPID”
Now we needed to create a couple of workflow variables for use in our calculation (add the ID to the number 6000). SharePoint stores ID as a string instead of a number so we will convert it to a number in the variable.
- On the actions menu, select “Set workflow variable”
- Click on workflow variable and click “Create a new variable…”
- Provide a name for the variable – we used StartNum
- The type should be Number
- Click on value and set the value to 6000
- Create another workflow variable – Click on Actions – “Set workflow variable”
- Click on workflow variable and click “Create a new variable…”
- Provide a name for the variable – we used IDValue
- The type should be Number
- Click on value and then click on the function button set the Source to: Current Item and the Field to: ID (This will convert the ID string to a number so it can be added to the number 6000)
- Click on Actions and choose “Do calculation”
- Click on the first value and then the function button and choose Source: Workflow Data, for Field: select Variable: StartNum
- Leave the operant as “plus”
- Select the second value and then the function button, choose Source: Workflow Data, Field: Variable:IDValue
- Output the value to a new variable – we used SPIDNum
Next we created a dynamic string to concatenate our SPID num with our calculated field called “CTRCCode”.
- Click Actions and select “Extract Substring from Index of String”
- Click on string and then click on the ellipses, click Add Lookup
- Source: Workflow Data, Field: Variable:SPIDNum – click OK
- Click on Add Lookup again
- Source: Current Item, Field: CTRCCode
- Click OK.
- Change number to 1
- Output the value to a new variable – we used the name SPIDID
The final step is to Set the field SPID # in the list to the variable we just created called SPIDID.
- Click on Actions – “Set Field in current item”
- Click on field and select SPID #
- Click on value and then the function button
- Source: Workflow Data, Field: Variable:SPIDID
When you are finished, your workflow Designer should look like this: (see attachment)
Rob am I adding your steps 1,2,3 to the workflow I already have set up or am I creating a brand new workflow with your steps?