Apr 05, 2024 01:42 PM
Any assistance would be greatly appreciated!
I have a Serial Number (SN#) that is labeled "Locker Name". I want to make sure that the SN# is 7 Characters/Digits before finishing the automation as sometimes it get typed in wrong. the SN# format is NS01234 or NS00123. People leave off the 0's from time to time. i want to create a new record with this number in a new table. Linking is not option here. Here is what i am trying to do but i am getting this error:
let sn = input.config.LockerName;
let updatedSN = '';
if (sn.length === 5) {
updatedSN = 'NS00' + sn.slice(-3);
} else if (sn.length === 6) {
updatedSN = 'NS0' + sn.slice(-4);
} else if (sn.length === 7) {
updatedSN = sn;
} else {
updatedSN = 'Invalid SN#';
}
output.set('updatedSN', updatedSN);
Solved! Go to Solution.
Apr 05, 2024 08:26 PM
Try adding a "()" to your "input.config", so:
let sn = input.config().LockerName;
let updatedSN = '';
if (sn.length === 5) {
updatedSN = 'NS00' + sn.slice(-3);
} else if (sn.length === 6) {
updatedSN = 'NS0' + sn.slice(-4);
} else if (sn.length === 7) {
updatedSN = sn;
} else {
updatedSN = 'Invalid SN#';
}
output.set('updatedSN', updatedSN);
A non scripting alternative could be asking your users to just key in the number and you can add the appropriate prefix via a formula field instead
Apr 05, 2024 08:26 PM
Try adding a "()" to your "input.config", so:
let sn = input.config().LockerName;
let updatedSN = '';
if (sn.length === 5) {
updatedSN = 'NS00' + sn.slice(-3);
} else if (sn.length === 6) {
updatedSN = 'NS0' + sn.slice(-4);
} else if (sn.length === 7) {
updatedSN = sn;
} else {
updatedSN = 'Invalid SN#';
}
output.set('updatedSN', updatedSN);
A non scripting alternative could be asking your users to just key in the number and you can add the appropriate prefix via a formula field instead
Apr 09, 2024 06:23 PM