Hi Isaac,
From my own experience I could provide some suggestions that may work.
In my applications padding with prefix zeros is quite commonly used. Given any numeric value I calculate the padded text value as follows:
CUT β00000β FROM (REMOVE β.000000β FROM (REMOVE β,β FROM (MAKE n A TEXT) ) ) TO END +
REMOVE β.000000β FROM (REMOVE β,β FROM (MAKE n A TEXT) )
Where:
- β00000β is any number of prefix zeros (or other characters) that equals the desired TEXT length minus 1.
- n is any numeric value you want to convert to padded text
- Local settings are set to US number format, for European format just switch commas and periods in the queries above.
So in your case, with a desired text length of 2 this would be:
CUT β0β FROM (REMOVE β.000000β FROM (REMOVE β,β FROM (MAKE n A TEXT) ) ) TO END +
REMOVE β.000000β FROM (REMOVE β,β FROM (MAKE n A TEXT) ).
If your numeric value already has a text format, you could of course use the NUMBER OF CAHARACTERS OF A function:
CUT β0000β FROM (NUMBER OF CHARACTERS OF a) TO END + a
For the daily counter I see two options:
Option 1:
Abandon the sequence value on data level and instead create a data-item that creates your own counters on organization or application level and create a flow part to:
- Retrieve the current value of the counter and add 1
- Save the new value back into the counter
- Use the new counter value to add it to your ID string
Then create an Automation Flow that resets the counter value to 0 each day at midnight.
Option 2
Based on the date value (or itsβ text equivalent) you could determine the new counter value by either:
- counting the currently saved requests with the same date/textvalue (new value would be count result plus 1) OR
- you could determine the highest value of the counter in a selection of requests that match the current date. You should then add an numeric attribute to your data-item for the counter, since that saves you building a complex query and will be more efficient when executed.
Both options are implemented using a search within a flow part for Requests where the text for the date value (e.g. β20230407β matches the first 8 positions of the Request ID, using CUT [RequestID] FROM 1 TO 8. Then you can use either COUNT ITEMS IN LIST A and add 1 to the result, or MAXIMUM OF A, where βAβ is the Counter attribute in the Requests List you have selected, and again add 1 to the result.
None of these methods of course are as solid as a sequence. There is always a risk that two users add a Request at the same time and thus create the same value for the counter, resulting in a duplicate value. There is a method to counter this, using an Automation Flow on a queue for creating the new records and/or IDβs, where the queue records do get a sequence and the flow handles the queue entries in the order of the sequence. With many users and requests there is a slight chance that this can cause some delay in processing new records on busy moments, but it does ensure data-integrity. Please note that this approach also increases the number of actions needed to create a record.
Hope this helps.