?
Solved

Custom Unique Number SharePoint Column using SP Designer Workflow

Posted on 2009-04-28
12
Medium Priority
?
800 Views
Last Modified: 2012-08-13
Dear Experts,
I have created a SharePoint Designer workflow that generates custom unique number on "item create". The problem is,
the number does not get generated immediately after the item is created. I have to refresh the page to see the generated ID.
Is there a way to avoid this delay?

Here is the sequence of event for better understanding
1. My List has the following fields: Unique ID, Title,......etc
2. Click on "New" to create a new item, fill out the fields and click OK
3. At this point of time, the Unique ID field is empty (the SPD workflow is in "in progress" state)
4. Refresh the page and you see the generated unique ID field (the SPD workflow status is now "completed")

My concern is to avoid this delay i.e., to get the unique number generated as soon as the item is created.
Is it possible to achieve this using workflows or should I resort to event handlers? If there is a better solution for generating custom Unique Numbers please let me know.

Thank you for reading my post patiently!
0
Comment
Question by:toramesh
  • 6
  • 5
11 Comments
 
LVL 17

Expert Comment

by:GreatGerm
ID: 24256687
You are at the mercy of the workflow gods when it comes to quickness of running.  You can use event handlers, form actions, or use the unique ID that SharePoint automatically assigns.
0
 

Author Comment

by:toramesh
ID: 24262834
Thank you for the ideas. One more question. Wether I take the workflow route or the event handler route, each time the ID is generated a new version is created. Is there a way to avoid or circumvent this issue? Because I don't want the users to restore it to a version before the ID was created. Once again I appreciate your contribution very much.
0
 
LVL 17

Expert Comment

by:GreatGerm
ID: 24263258
Do they need to be able to see the different versions?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:toramesh
ID: 24264219
Well, if they want to roll back to a previous version of that item, they typically naviagte to the version history page for that item and if they do, they get to see a version without the ID and a version with the ID. Since the workflows or event handlers create the ID after the item itlsef is created, it is treated as a new version
0
 
LVL 17

Expert Comment

by:GreatGerm
ID: 24264318
If they didn't need to be able to roll back to previous versions I would say just remove the view versions permission. Is there a reason you don't want to use the ID generated by SharePoint?
0
 

Author Comment

by:toramesh
ID: 24264422
Workflow fires after a record is created, and if we have version history turned on, version 2.0 is created when the ID is generated. A user could restore version 1.0 and the net effect is that the generated ID number could be deleted.
0
 
LVL 17

Expert Comment

by:GreatGerm
ID: 24265810
Right, but SharePoint has a unique ID that it assigns to every item on creation.  Go to a view in any list and edit it to show the ID column and you'll see what I mean.
0
 

Author Comment

by:toramesh
ID: 24271624
Yup I know about the ID column, but my requirement is to conatenate ID number with date and generate numbers with 4 digit positions in it. Calculated fields do not work with ID column as the calcuation occurs before the ID is generated for a row. So it would always consider ID as 0. The ID number should also get reset each year. So it looks like custom code to me. And the users do need versioning. That is one of the requirements. Thank you very much for patiently following up with this thread. I am yet to figure out a way to avoid version 2.0 from getting created when ID number is created (both workflow and event handlers create ID numbers by creating another version).
0
 
LVL 17

Expert Comment

by:GreatGerm
ID: 24271780
The quick way would be to hide your custom ID column in the new item form and use javascript to create your string and assign it to the text box of your custom ID.  That way it's there on the initial version.
0
 

Author Comment

by:toramesh
ID: 24274360
Good suggestion, but how do I access SharePoint's custom list's column using javascript? In other words where do I write this code?
0
 
LVL 17

Accepted Solution

by:
GreatGerm earned 500 total points
ID: 24274771
You would put the code in the NewItem.aspx page itself. If you don't plan on changing your columns much you can just have it call specifically to that generated ID (you'll have to look at the generated code to see what it is).  If you want to do customization more often I would recommend using jQuery (http://www.jquery.com).
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question