how to set value for string field having choices using fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2022 02:39 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2022 02:52 AM
Hello,
Since it's string field and choice is not available it will show in blue. Kindly create new choice "FY-22/23" and then try to set with this value (not sys id), it will be in black color only.
Thanks
Akshay Kangankar
Please Mark ā
Correct/helpful, if applicable,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2022 02:55 AM
Hi,
please give the choice value and not the choice label or sysId
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2022 03:12 AM
Thanks, It's working now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-29-2022 09:02 PM
Glad to know.
Please mark my response as correct and close the thread.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader