Can I pad a value before insert from record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 11:31 AM - edited 05-03-2024 11:33 AM
I have a requirement that a value be a specific length when inserted on the form from a record producer, without making the user meet the requirement. I've attempted an onSubmit Client Script but it isn't working. The variable is a string.
var hours = g_form.getValue('variable').length;
var size = 10;
while (hours < size){
hours = "0" + hours;
}
g_form.setValue('variable', hours);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 11:02 PM - edited 05-04-2024 11:07 PM
Hello @eptnavyguy
You are adding 0 to length, not the variable value. try below script:
var hoursValue = g_form.getValue('variable');
var size = 10;
while (hoursValue.length < size){
hoursValue = "0" + hoursValue;
}
g_form.setValue('variable', hoursValue);
You can try this script in onchange script as well. which will make user also know about this.
Thank you,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 06:28 AM
Unfortunately, that didn't work. I appreciate your help.