- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 01:58 PM
Hello All,
I need to add the suggestions on the Emp Code fields based on the combination of First Name and Last Name initials along with 3 digits to select for the new user.
How can I achieve the suggestions underneath the Variable field?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 06:13 PM - edited 12-27-2023 06:19 PM
Hi @kpanchal, You can try with the onChange client script on variable name 'lastName' to get the dynamic suggestions and you need to make sure the value in lastName is entered. You can probably make the Id field readOnly untill the last is populated.
Dynamic Option:
onChange Client Script:
Static Options:
You can try with example text on the variable form or show the field message using the catalog client script.
Client Script:
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 10:31 PM
Hello @kpanchal ,
You can user below catalog client script to generate dynamic Employee Code. As a result it will give you Combination of the initials of the First Name and Last Name fields with the random 3-digit number to form the Emp Code.
*** this script running on Onchange for last Name variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var firstName = g_form.getValue('first_name');
var lastName = g_form.getValue('last_name');
var empCode = firstName.charAt(0) + lastName.charAt(0) + generateRandomNumber();
g_form.showFieldMsg('employee_code', 'Suggested Emp Code: ' + empCode, 'info',true);
}
function generateRandomNumber() {
return Math.floor(100 + Math.random() * 900);
}
After generating the code you can add more checks and conditons based on your business requirement.
Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.
Regards,
Siddhesh