how to append the drop down field values?

Are Kaveri
Tera Contributor

Hello ,

 

I was working on a custom form.

there is a checkbox field on Representative table called validFlag = Boolean

there is Employee table in that we are having Frequent flag (string with drop down values Yes/No)= validFlag(representative table field) + grade (present on Employee table)

 

Before we use to copy validFlag (true/false)= Frequent flag (Yes/No)

we have before update Business rule

var gr = new GlideRecord('representative');
    gr.addQuery('sys_id', current.representative);
    gr.query();
    if (gr.next()) {
        if (gr.validflag == true) {
            current.setValue('frequentflag', 'yes');//Now Frequent flag = validFlag + Grade
        } else {
            current.setValue('frequentflag', 'no');
        }

    }
    

How to append validFlag and Grade and set to Frequent flag?

1 ACCEPTED SOLUTION

sunil maddheshi
Tera Guru

@Are Kaveri 

Try to concatenate the validFlag (converted to "Yes"/"No") with the Grade field value, please try with below script:

var gr = new GlideRecord('representative');
gr.addQuery('sys_id', current.representative);
gr.query();
if (gr.next()) {
    var validFlagValue = gr.validflag ? 'Yes' : 'No'; // Convert boolean to Yes/No
    var gradeValue = current.grade || ''; // Ensure grade is not null

    var frequentFlagValue = validFlagValue + ' ' + gradeValue; // Append values

    current.setValue('frequentflag', frequentFlagValue.trim()); // Remove any trailing spaces
}

Please mark correct/helpful if this helps you!

View solution in original post

7 REPLIES 7

@Are Kaveri 

but how Frequent flag will show Yes 10 if the choice is only Yes?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

that what i am not understanding how i should add this value 

validFlag = true and Grade = 10

Frequent flag = Yes (validFlag) + 10(how to convert true to Yes)?

@Are Kaveri 

please discuss with your customer about this requirement.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader