How can add suggestions on the variables field on catalog form

kpanchal
Tera Contributor

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?

kpanchal_0-1703714253885.png

 

1 ACCEPTED SOLUTION

SunilKumar_P
Giga Sage

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:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var firstLetter = g_form.getValue('first_name').split('')[0];
    var lastLetter = g_form.getValue('last_name').split('')[0];
    var randomNumber = Math.floor(Math.random() * (999 - 100 + 1) + 100);
    var finalId = firstLetter + lastLetter + randomNumber;
    g_form.showFieldMsg('unique_id', 'Suggested Id is - ' + finalId, 'info');
}

 

SunilKumar_P_4-1703729935423.png

 

Static Options:

 

You can try with example text on the variable form or show the field message using the catalog client script.

 

Client Script:

function onLoad() {
   g_form.showFieldMsg('unique_id', 'Please Enter Uique Id', 'info');
}

 

SunilKumar_P_0-1703728211549.pngSunilKumar_P_1-1703728256023.pngSunilKumar_P_2-1703728282811.png

 

Regards,

Sunil

 

 

View solution in original post

10 REPLIES 10

Sainath N
Mega Sage
Mega Sage

@kpanchal : You want to add static suggestion "based on the combination of First Name and Last Name initials along with 3 digits" or is there any dynamic logic behind it? Could you elaborate to help better.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

I want dynamic code suggestions

@kpanchal : Could you elaborate your ask with an example on how we will get the dynamic suggestions so that we will be able to help you better.

Hi @Sainath N ,

My 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.