- 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 02:27 PM
@kpanchal : If it's a static message, you can configure the code in the onchange client script as per below.
function onChange(control, oldValue, newValue, isLoading) {
g_form.showFieldMsg('employee_id', 'Enter based on the combination of First Name and Last Name initials along with 3 digits', 'info');
}
Appearance:
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards 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 06:36 PM
Hello Sunil, I need dynamic options.
How can I get multiple suggestions with these combinations.
In your code, it only gives 1 suggestion but for me I need multiple suggestions so that user can select one of code.
My Acceptance Criteria along with Scenario is:
Scenario Description:
For employees associated, existing employee codes adhere to the AA99 format. If an existing employee leaves and returns within 400 days, they will regain their previous employee code in the AA99 format.
For new employees requesting an employee code for the first time, the following criteria must align:
1. Provide code suggestions.
2. Generate a new code in the AA999 format.
3. Once a suggestion is offered, the code remains reserved until the employee either submits or selects a different code.
Acceptance Criteria:
Fields:
- Status: Free/Reserved/Assigned/Blocked/Completed
- Employee Code: Unique key combining AA99 (for old employees) & AA999 (for new employees). It will include the employee's first and last name initials. (EMP CODE = FIRST INITIAL + LAST INITIAL + 2/3 DIGITS)
- Employee ID: Reference field to Sys ID
- Date: Readonly once code allocation occurs
- SN Fields: Basic fields
- Name: FreeText
Conditions:
For Old Employees:
- If an employee previously had an EMP code, leaves RCGT, and returns within 400 days, they will retain their original EMP code.
For New Employees:
- Upon meeting criteria, additional conditions apply:
1. STATUS remains locked at RESERVED if the user selects a code from suggestions but does not submit.
2. STATUS changes to RELEASE if the user fails to submit within a one-hour period.
3. STATUS changes to ASSIGNED once the user submits and the code is allocated.
4. STATUS changes to Terminate if the employee leaves and does not return within 400 days.
Note: Reserved codes will be released back into the suggestion pool if the user selects a different code after initially choosing one and not submitting it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 10:28 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 10:30 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