
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-29-2018 06:04 PM
Hi Team,
Hopefully an easy one as I can't see why this won't work for me.
I have a Record Producer with a number of variables and when I submit the form I want to grab a few variables and copy to the description field. This works for all variables, but for the 'Select Box' it shows the 'value' and not the 'text'.
To grab the variable in the script are I enter the following:
current.description = 'Course Provider: ' + producer.u_course_provider. This works for all variables
For the course providers I have entered these in the following format: Text 'Company A' and the value is 'company_a'.
I can't seem to refer to the 'text' and all I get back is the 'value' - so the value of 'company_a' but I need 'Company A' as it's the friendly name I need to show in the description field.
I haven't entered the 'value' as the 'friendly name, with spaces and caps' as my understanding is that this isn't the recommended way to enter stored values. I could rename all my 'values' to the same as the 'text' - but before I did this I need to confirm that this won't cause any issues. The product documentation isn't clear if this is the correct way of adding question choices or nor?
Can anyone help with this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-24-2018 11:11 AM
Hey Carl, I'm probably too late here but I just came across your post as I was experiencing the same challenge due to a requirement I have to make our select box question choices differ between the text and value.
I tried a lot of different things from what I'd seen on the community and in ServiceNow documentation, but it turned out Sanjiv was very close in giving you the correct answer.
Instead of this: producer.u_course_provider.getDisplayValue();
It should be this: producer.getDisplayValue('u_course_provider');
Here's how I'm handling my record producer output:
producer.getDisplayValue('u_course_provider'); //provides the choice text - friendly display
producer.u_course_provider; //provides the choice value
producer.u_course_provider.getGlideObject().getQuestion().getLabel(); //provides the field label if you don't want to hardcode the label in your RP output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-24-2018 11:11 AM
Hey Carl, I'm probably too late here but I just came across your post as I was experiencing the same challenge due to a requirement I have to make our select box question choices differ between the text and value.
I tried a lot of different things from what I'd seen on the community and in ServiceNow documentation, but it turned out Sanjiv was very close in giving you the correct answer.
Instead of this: producer.u_course_provider.getDisplayValue();
It should be this: producer.getDisplayValue('u_course_provider');
Here's how I'm handling my record producer output:
producer.getDisplayValue('u_course_provider'); //provides the choice text - friendly display
producer.u_course_provider; //provides the choice value
producer.u_course_provider.getGlideObject().getQuestion().getLabel(); //provides the field label if you don't want to hardcode the label in your RP output

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-04-2018 05:45 PM
Hi Joe,
Thanks for your message - the updated code:
producer.getDisplayValue('u_course_provider');
worked a treat, so this now grabs the text not the value.
For some reason I can't get the below to work, the entire description is now blank:
producer.u_course_provider.getGlideObject().getQuestion().getLabel();
but it's not essential for my requirement as I have just hard-coded the labels for now. Will play around with it a bit more - maybe Sanjiv's script might work here. I'm entering all my values in the 'script' field - as per below.
current.description = producer.opened_for.name + ' has requested to attend external training' + "\n" + 'Employee Number: ' + producer.u_employee_number + "\n" + 'Employee Location: ' + producer.opened_for.location.name + "\n" + 'Business Group: ' + producer.opened_for.u_business_group + "\n" + 'No of External Courses attended this year: ' + producer.u_no_external_courses + "\n" + 'No of External Courses planning to attend: ' + producer.u_no_ext_courses_proposed + "\n" + 'Course Name: ' + producer.u_course_name + "\n" + 'Course Name Other: ' + producer.u_course_name_other + "\n" + 'Course Provider: ' + producer.u_course_provider + "\n" + 'Course Provider Other: ' + producer.u_course_provider_other + "\n" + 'Course Location: ' + producer.u_course_location.name + "\n" + 'Course Location-Other: ' + producer.u_location_other + "\n" + 'Course Category: ' + producer.u_category + "\n" + 'Course Start Date: ' + producer.u_course_start_date + "\n" + 'Course End Date: ' + producer.u_course_end_date + "\n" + 'Course Cost: ' + producer.u_training_cost + "\n" + 'Estimated Travel Cost: ' + producer.u_estimated_cost + "\n" + 'Project/Task No: ' + producer.u_project_task_no + "\n" + 'Prerequisite Reason: ' + producer.u_prereq_reason + "\n" + 'Identified in PDPR: ' + producer.u_pdpr + "\n" + 'Line Manager: ' + producer.u_line_manager.name + "\n" + 'Lv4 Manager: ' + producer.u_level4_manager.name + "\n" + 'Lv3 Manager: ' + producer.u_level3_manager.name + "\n" + 'Level 2 Manager (>$500 only): ' + producer.u_level2_design_centre.name + "\n" + 'Supporting Comments: ' + producer.u_description;