How to get choice list value of a filed through Rest API.

jobin1
Tera Expert

Hi All,

 

We have a custom table called u_email_client and here we have a filed called u_status.

The requirement is whenever the insert is happening that time it should be set u_status choice list to Received(this Received choice list option is already available we need to utilize the same).

How we can achieve this?

i tried below script in rest API but not working

var emailClient = new GlideRecord('u_email_client');
emailClient.initialize();
emailClient.u_subject = short_description;
emailClient.u_status ="ed2ee3a3376aba0021865ca543990e5a";//sys id of choice list "Received"
emailClient.u_item = num2;

emailClient.insert();

find_real_file.png

find_real_file.png

 

@Ankur Bawiskar Any idea?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

it's choice and not reference so give value

var emailClient = new GlideRecord('u_email_client');
emailClient.initialize();
emailClient.u_subject = short_description;
emailClient.u_status ="Received"; // give choice value here
emailClient.u_item = num2;

emailClient.insert();

Regards
Ankur

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

View solution in original post

3 REPLIES 3

jobin1
Tera Expert

@Ankur Bawiskar Any idea?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

it's choice and not reference so give value

var emailClient = new GlideRecord('u_email_client');
emailClient.initialize();
emailClient.u_subject = short_description;
emailClient.u_status ="Received"; // give choice value here
emailClient.u_item = num2;

emailClient.insert();

Regards
Ankur

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

jobin1
Tera Expert

Thanks Ankur. I tried the same initially but the spell was wrong.