I wish to generate a random 5=digit ID whenever a process is initiated. For exa

I wish to generate a random 5=digit ID whenever a process is initiated. For example; when a user launches a process I want to have on the form (read-only) a 5-digit ID field where it is populated with this random number and then stored in a PV like submissionID. ...

OriginalPostID-63546

OriginalPostID-63546

  Discussion posts and replies are publicly visible

  • Is the number supposed to unique? If not, you can use rand() to generate a random number. forum.appian.com/.../Mathematical_Functions
  • If you want it random within the process then the rand() function that Mike suggests will work well. Are you looking for a random number across all process instances? You could also leverage, the pp!id of the process instance as it is different for each process instance in Appian. If you are looking for a unique id to identify each submission from the other, you could explore the option of using a database table to store the submission data. Have a primary key associated with each record in the table, which becomes the id you are looking for. Let us say you are using a CDT to save the data into the database table, then you can annotate the primary key field with @Id and @GeneratedValue in the XSD of the CDT. @Id is used to make the field unique and @GeneratedValue is used to make it an autogenerated number. Everytime you insert a record into the table using the Write to Datastore smart service, a new ID will be generated for that record.
  • If you are looking for a unique id to identify each submission from the other, you could explore the option of using a database table to store the submission data. This is what I am looking for. However, can I expose this unique ID in a form as a process variable? This way users can reference the ID if needed
  • Yes, you can do that. The record written into DB can be got from the outputs tab of the Write to Datastore node. In the ouputs tab, you can save the record into a PV of type CDT. If you look at the id element of the CDT, the value will be there.