Question
Coforge
GB
Last activity: 28 Sep 2017 10:33 EDT
Unique identifier
How to generate a unique identifier?
Message was edited by: Vidyaranjan Av| Included Category
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 9 Mar 2016 7:19 EST
Pegasystems Inc.
IT
Hi Shirisha,
I suppose you refer to the Work- GenerateID activity which is available and can be customized.
So, as long as using the GenerateID activity is getting close to the desired outcome, you can customize it to achieve your goal.
E.g.: you can save it as MyGenerateID then modify the java code at step 2 adding lines 4-13:
Hi Shirisha,
I suppose you refer to the Work- GenerateID activity which is available and can be customized.
So, as long as using the GenerateID activity is getting close to the desired outcome, you can customize it to achieve your goal.
E.g.: you can save it as MyGenerateID then modify the java code at step 2 adding lines 4-13:
try { // We no longer supply the organization for getDataUniqueID. String nextID = tools.getDatabase().getDataUniqueID("", tools.getParamValue("IDPrefix"), tools.getParamValue("IDSuffix")); // Customization START (pad the sequence value with a leading 0) int start = nextID.indexOf(tools.getParamValue("IDPrefix")) == 0 ? tools.getParamValue("IDPrefix").length() : 0; int end = nextID.lastIndexOf(tools.getParamValue("IDSuffix")) > 0 ? nextID.lastIndexOf(tools.getParamValue("IDSuffix")) : nextID.length(); int seq = Integer.parseInt(nextID.substring(start, end)); String nextValue = String.format("%02d", seq); //System.out.println("nv: " + nextValue); //System.out.println("ID before: " + nextID); nextID = String.format("%s%s%s",tools.getParamValue("IDPrefix"), nextValue, tools.getParamValue("IDSuffix") ); //System.out.println("ID after: " + nextID); // Customization END ...
This modified activity, executed with parameters (IDPrefix:"sa-", IDSuffix:""), produces the following output (with debug statements uncommented):
nv: 01
ID before: sa-1
ID after: sa-01
...
nv: 10
ID before: sa-10
ID after: sa-10
Pegasystems Inc.
GB
Hi Shirisha ,
Can you provide a bit more detail: do you mean a Work Item Identifier (eg SR-nnnnn ?) : something unique to your application to identify a particular Work Item ?
Or something globally unique (like a UUID ?)
Thanks
John
Coforge
GB
Hi John,
I need to generate a Unique identifier( can say a reference id to a customer) taking customer last name plus a 2 digit unique identifier. I am able to generate id using GenerateID activity but it starts as 1, something like "John1", but my requirement is to generate as "John01".
Thanks
Shirisha
Accepted Solution
Updated: 9 Mar 2016 7:19 EST
Pegasystems Inc.
IT
Hi Shirisha,
I suppose you refer to the Work- GenerateID activity which is available and can be customized.
So, as long as using the GenerateID activity is getting close to the desired outcome, you can customize it to achieve your goal.
E.g.: you can save it as MyGenerateID then modify the java code at step 2 adding lines 4-13:
Hi Shirisha,
I suppose you refer to the Work- GenerateID activity which is available and can be customized.
So, as long as using the GenerateID activity is getting close to the desired outcome, you can customize it to achieve your goal.
E.g.: you can save it as MyGenerateID then modify the java code at step 2 adding lines 4-13:
try { // We no longer supply the organization for getDataUniqueID. String nextID = tools.getDatabase().getDataUniqueID("", tools.getParamValue("IDPrefix"), tools.getParamValue("IDSuffix")); // Customization START (pad the sequence value with a leading 0) int start = nextID.indexOf(tools.getParamValue("IDPrefix")) == 0 ? tools.getParamValue("IDPrefix").length() : 0; int end = nextID.lastIndexOf(tools.getParamValue("IDSuffix")) > 0 ? nextID.lastIndexOf(tools.getParamValue("IDSuffix")) : nextID.length(); int seq = Integer.parseInt(nextID.substring(start, end)); String nextValue = String.format("%02d", seq); //System.out.println("nv: " + nextValue); //System.out.println("ID before: " + nextID); nextID = String.format("%s%s%s",tools.getParamValue("IDPrefix"), nextValue, tools.getParamValue("IDSuffix") ); //System.out.println("ID after: " + nextID); // Customization END ...
This modified activity, executed with parameters (IDPrefix:"sa-", IDSuffix:""), produces the following output (with debug statements uncommented):
nv: 01
ID before: sa-1
ID after: sa-01
...
nv: 10
ID before: sa-10
ID after: sa-10
Coforge
GB
Hi Domenico,
It generates ID from 01 sequence right. Is there any way to make it to start the sequence from 00?
Thanks
Shirisha
Updated: 10 Mar 2016 5:29 EST
Pegasystems Inc.
IT
Hi Shirisha,
The incremental value is retrieved from SP sppc_data_uniqueid which is used to generate Work Item Identifiers.
This SP starts with 1 in case of new prefixes.
Please note that any change to that SP will apply to generated identifiers for all work objects.
So make sure to thoroughly test your application in case you should decide to change the stored procedure.
I've suggested the previous change because it was trivial to implement and it does not introduce side effects (if you chose a different identifier for the activity).
If you have different requirements it might make sense to consider the option to implement a fully independent solution in order to avoid impacting OOTB functionalities.
Cheers,
Domenico
Coforge
GB
yeah, thanks
Pegasystems
FR
Perhaps this can be of some help. Smart Investigate générâtes out of the box the Pega ID in the format:
PPPYYMMDD-nnnnnn
Where PPP is the prefix, then the year and finaly a fixed length for the incremental id number. (like 000001).
You would need to get your hands on the activity GenerateID from Smart Investigate and derive from that.
Hope this helps.
Pegasystems Inc.
IT
For Work Item Identifiers you may want to review the following help page: https://community.pega.com/sites/default/files/help_v719/procomhelpmain.htm
If you want a generic ID not related to a work item, the UUID that John cited, is a good solution.
You can easily generate them using the @java built-in function to create a random UUID (Java Platform SE 7 ) in this way:
@java("java.util.UUID.randomUUID().toString()")
Such an expression can be referenced in a Declare Expression or in a Data Transform rule.
E.g.: The following form references two Text properties UniqueID and AnotherID both containing UUID values:
For Work Item Identifiers you may want to review the following help page: https://community.pega.com/sites/default/files/help_v719/procomhelpmain.htm
If you want a generic ID not related to a work item, the UUID that John cited, is a good solution.
You can easily generate them using the @java built-in function to create a random UUID (Java Platform SE 7 ) in this way:
@java("java.util.UUID.randomUUID().toString()")
Such an expression can be referenced in a Declare Expression or in a Data Transform rule.
E.g.: The following form references two Text properties UniqueID and AnotherID both containing UUID values:
The former is calculated using the following Declare Expression:
The latter is calculated using the following Data Transform:
This is how the field are assigned in the form at runtime:
Truviq Systems
NL
Hi Siri,
Domineco pointed to right articles of WokID (if it's for Case ID) and UUID.
If your query is not related both the scenario's. Please point us in the right direction with specific details.
If any records would required to be hold unique ID when you get input from external sources, please have dedicated to table to that class.
We can set the value to default properties like pyID to make it as unique identifier for your record. You may optimize your own property as Unique ID too.
If your requirement to generate unique ID using few properties values combination, please refer to 2nd-step of "GenerateID" activity in Work- class.
You can add up multiple properties values to param, pass the param to unique key of your record or instance. It will generate ID with combo value.
Thanks for sharing your thoughts.
--Chaitanya
VISPL
IN
I need to create a policy number depending on the properties we had had entered
Example-
1)if policy Cover type is Full Cover
2)if the vehicle is Car and date is 1/1/2007
then policy no. should be :FC20071
can anyone help mi wid it?