How to get Display Value from a List type field using Server side script

Are Kaveri
Tera Contributor

Hi 

 

I am working on a Custom application.

 

we have field called Address , type of field= List

 

I want to add this field to popup. i am using below code to get display Value but it is displaying sys_id.

How to get Display value from list 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here

    var duplicateCase = new GlideRecord('x_sor_goods_service_case');

    if (!gs.nil(current.req_number) && !gs.nil(current.identification_address)) {
        //duplicateCase.addActiveQuery();
        duplicateCase.addQuery('sys_id', '!=', current.sys_id);
        dduplicateCase.query();

        if (duplicateCase.next()) {
            current.state = '3'; //Closed
            current.close_notes = 'This case is duplicate of ' + duplicateCase.number + '. Has the same request number and address: ' + current.req_number + " -> " + current.getDisplayValue('identification_address') + '.';
            current.setWorkflow(false);
            current.autoSysFields(false);
            current.update();
            return;
        }
    }
   
})(current, previous);

 

1 ACCEPTED SOLUTION

@Are Kaveri 

that list field refers to which table?

On that table any field is marked as Display=true?

if not then it will give sysId

If some field is marked as Display=true then it will show that

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Are Kaveri 

try this line

current.identification_address.getDisplayValue()

            current.close_notes = 'This case is duplicate of ' + duplicateCase.number + '. Has the same request number and address: ' + current.req_number + " -> " + current.identification_address.getDisplayValue() + '.';

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
Tera Patron
Tera Patron

@Are Kaveri 

Please mark my response as correct to one of your earlier question since it worked for you

how to copy Task skills related list values to a List type field in servicenow 

 

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

@Ankur Bawiskar ,

Actually i am doing getDisplayValue() only not working.

 

tried both approach it is showing sys_id not display value.

 

 

@Are Kaveri 

that list field refers to which table?

On that table any field is marked as Display=true?

if not then it will give sysId

If some field is marked as Display=true then it will show that

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