Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

how to set value for string field having choices using fix script

Apoorva Kadu
Tera Contributor

I want to insert a record with fiscal year field value, on form it is choice field but in backend it's a string 

tableRec = new GlideRecord('cost_plan');
tableRec.initialize();
tableRec.name = 'Test costplan4';
tableRec.task = 'ff80cc231bb3f89c2473eb19b04bcb43';
tableRec.u_fiscal_year = 'FY-22/23'; // if am giving direct choice value it is coming in blue color 

OR

tableRec.u_fiscal_year = 'af36cf62dbad9c509a88b1b239961937';  //if am giving sys_id of (FY-22/23) then sys_id is coming in the field.
tableRec.insert();

What is the correct method to insert choice from choice list 

 

5 REPLIES 5

@Apoorva Kadu 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

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