I would like to change my rule for generating of case number.
At this moment I'm using something like this
"APP" &text(now(),"yy") &text(now(),"mm") &text(now(),"dd")& "-" &ri!request.id,
where id is id of my case in DB. This number for example is "APP-191004-10".
I would like to change this rule for having "id" reseting every day. What i mean is for example users create 100 case this day so we start APP-191004-1 and the last number for today would be APP-191004-100. On the next day this number starts from 1 APP-191005-1. Can you help me with remaking this rule
Hi Dawid - You can have a constant of type number(integer) that would function as the "id" of the case in your database. This constant would be set to 1 initially and would be incremented by 1 after a case is created. You would have to update this constant to 1 via a nightly process so that the "id" is reset every day.
Is this “number” stored in the DB? If so, another approach is to make a view to return a 1 or 0 or next number with the use of CASE statement to check if none in for today.
Hope that gives you another approach
Can there only be a maximum of 100 cases per day?
I've done this before in the following way:
(Use of a Stored Proc is more robust as it allows you to lock the current row and thus ensure concurrent requests to it do not result in the same value being retrieved/written)
Another option here would be to utilize a constant for the daily ID value, create a sub process that gets this information for each record. Assuming you have a 'CreatedOn' timestamp for each record, the sub process can query the DB to see if any requests have been created in the same day. If not, reset the constant to 1 and return that value. If so, increment the constant and return the incremented value.
Remember Appian saves previous versions of constants when they are changed. This uses memory.The constant approach suggested above is easy to build, but it may not scale well over time.I'd use a variant of what Stewart Burchell recommends.
Hi Robert, to note in my experience Appian does not save a version to memory of a numeric constant that is incremented using the Increment Constant node so this is scalable. Constant versions are saved during manual updates, or when a constant is modified using the Update Constant node.
To add, for retaining scalability when resetting the constant I would recommend utilizing the Increment Constant node with a negative value (the negative value of the constant) to reset to 0, then perform the increment to get the first value (1) for the day, and no versions will be logged, vs using the Update Constant node to reset which would log a version each day.
Not bad, Chris. I am corrected.
So there's a small expression needed to obtain the value of the constant in order to properly reset it in this way.
I might do this next time.
Discussion posts and replies are publicly visible
© 2019 Appian. All rights reserved.