- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 11:34 AM
Hello
I have a custom table with the fields for: userid, firstname and last name. If the user fills out the form for first name and last name then hit submit. I want automatically generate the userid on the field in the table. I used business rule for this. I'm not sure why it's not generating the userid. Please help !
Thank You
When to run: After. Method: Insert
code below:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 11:40 AM
Looks like there is a spelling issue
var cal = Math.floor((Math.ramdom() * 2) +1);
instead of ramdom, use random.
You may also want run it before insert, so that you dont need a current.update().
Also may need to check, there are no existing users with the same username.
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 11:40 AM
Looks like there is a spelling issue
var cal = Math.floor((Math.ramdom() * 2) +1);
instead of ramdom, use random.
You may also want run it before insert, so that you dont need a current.update().
Also may need to check, there are no existing users with the same username.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 12:28 PM
It works. It generated the userid in the field. But i'm running into an issue that it's generating the same id for the person who has the same first name and last name. I tried to modify the code: var cal = Math.floor((Math.ramdom() * 100) +1); How do you make it unique so it wouldn't have duplicate userid later.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 12:44 PM
I would multiply by 1000, for ex i get more unique numbers
Math.random().toString(16).slice(2)
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 09:42 PM
Thanks so much !