- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 07:06 AM
I have created a Record Producer in the service catalog that contains a Lookup Select Box that shows a list of templates by their short description. What I would like to happen is when the user selects a template from the Lookup Select Box a new change is created and the specific template they selected is applied to the newly created change. Right now I have a template statically assigned in the tab labeled "Generated Record Data" in the record producer screen. So no matter what template they select from the Lookup Select Box, the template that I have statically assigned is applied to the change that is created.
Is there a way to apply the template that the user selects from the Lookup Select Box to apply to the new change, using a record producer?
Ex: Lookup Select Box options:
Template A
Template B
Template C
If the user selects Template C, then Template C would be applied to the new change created by the Record Producer. I know this could be accomplished using multiple Record Producer's, one for each template. However, I am wondering if I could accomplish this using a single Record Producer.
Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 09:07 AM
In your lookup select box, make sure the Lookup value field in the Type Specifications section is the set to the name of the template as that is what the applyTemplate function is expecting. then in your script you would have:
current.applyTemplate(producer.LookupSelectBoxVariableName);
The producer.LookupSelectBoxVariableName value would be set to the Template name chosen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 07:10 AM
You should be able to do this in the record producer script.
Creating a Template - ServiceNow Wiki
Remove the hard coded template from the record producer and then in the script put something like following near the end of your script:
current.applyTemplate(producer.VARIABLENAME);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 07:29 AM
Ok. I had been reading that Wiki and I think this suggestion makes sense. Noob question of the day...how do I navigate to the record producer script to edit it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 07:39 AM
No worries! Go to the record producer you are working with and its in the What it will contain section (or tab if you prefer tabs) in a field called Script. 'current' is the record it is producing while 'producer' is the data from the record producer and the variables can be used by producer.VARIABLE-NAME.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 09:00 AM
Great, I had found that screen earlier and kept missing it. Now I have gotten the script logic to behave how I am wanting by using current.applyTemplate("TemplateNameHere"); however I need to adjust it to consider which option the user clicks on using the Lookup Select Box. What I am wanting to accomplish:
Lookup Select Box options:
Template A
Template B
Template C
When the user makes their selection from the Lookup Select Box then the script should applyTemplate(userSelection);
How might I accomplish this using JavaScript within ServiceNow?