on 2025 Jan 09 1:33 PM
Hello,
I am creating a process automation form in SAP Build Process Automation. I am trying to configure the form to generate an auto-generated sequential ID number and send it by email to the approver.
I used the script option, but it does not seem to be working.
Do you have any guidelines on how to achieve this?
Request clarification before answering.
Hi @ElyasD ,
Agree with @Dinu , there is no way you can achieve this via custom scripting. You can generate a randomize ID number.
Something like this:
Function generateUniqueRandomNumberString(length) {
const timestamp = Date.now().toString();
let randomPart = '';
const characters = '0123456789';
const charactersLength = characters.length;
for (let i = 0; i < length - timestamp.length; i++) {
randomPart += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return timestamp + randomPart;
}
// Example
const uniqueRandomNumberString = generateUniqueRandomNumberString(20);
console.log(uniqueRandomNumberString);What I have implemented on my project was. The generated ID was saved somewhere (S4 Table, Database,Excel). The automation has to get the last ID# in able to add the corresponding sequence.
Regards,
weisson
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Dinu
I did a very simple scripting just to generate the code. But unfortunately, it did not work.
The Script Task has some constraints, described here: https://help.sap.com/docs/build-process-automation/sap-build-process-automation/restrictions-on-scri...
One of them is no Functions, so that script will not work.
The following script worked for me, modified from @arroyoweisson's script.
var length = 15;
var timestamp = Date.now().toString();
var randomPart = '';
var characters = '0123456789';
var charactersLength = characters.length;
var i;
for (i = 0; i < length - timestamp.length; i++) {
randomPart += characters.charAt(Math.floor(Math.random() * charactersLength));
}
$.context.custom.mynumber = timestamp + randomPart;I created a custom variable called "mynumber", to which I return the number (instead of using return).
For your simpler one (though you get characters because of radix 36):
var uniqueID = new Date().getTime().toString() + Math.random().toString(36).substring(2, 10);
$.context.custom.mynumber = uniqueID;HTH
P.S.: I don't see how this will get you a sequence number, though it will give you numbers going higher.
😺
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ElyasD,
I have same requirement as your requirement.
And firstly, I would like to apologize for asking another question instead of answering your question.
If you don't mind, could you please answer for me?
For mail sending step, what kind of mail type (eg. gmail, outlook) do you use.
In my case, I would like to use outlook mail, but the following error is keep occurring.
So, if you use outlook mail setting and possible to create without any issue, could you please share with me how to create mail setting for outlook mail type?
Best Regards,
Aye Chan
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.