Round off value in random pin generation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 02:19 AM
Hi all,
I have a requirement to generate Random 6 digit PIN. I have created a flow action and I am able to generate the 6 digit PIN. In Flow designer I have an action to send an Email along with random 6 digit PIN. When I check the flow Its giving me some random 6 digit Number without decimal. But when I check email logs , in email body I can see decimal has been added like if PIN is 144977 instead of its showing '144977.0' .
I have written below script in flow action:
(function execute(inputs, outputs) {
// ... code ...
//var random_pin = Math.floor(100000+Math.random()*900000);
var random_pin = Math.round(Math.random() * 1000000);
outputs.pin = random_pin;
})(inputs, outputs);
Can anyone help me on this. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 02:48 AM
Hi @Hareesha ,
Try using outputs.pin = parseInt(random_pin) in the above code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 03:00 AM
Hi @Hareesha ,
You can simply use transform functions while passing value in email content line below. Select "convert string to number" under string and apply. Thats it.
Hope that helps.
Thanks,
Sonam