How to get template values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2016 12:56 PM
hi team
i have record producer which having field template ,this template consist two field configuration item and assignment group
i have written below code in record producer script to populate the fields value into the configuration item and assignment group.
in the below i want to get the template value and i want to store the the number of filelds into separate variable and that value i want to
populate into configuration item and assignment group.
but in the below code i am not able to get the template value and not able to do put into array and
how to populate this values into configuration item and assignment group.
so please provide me your code
except appyTemplate method because if i am using applytemplate method
then there is two same number record is going to create
var templateList = "";
var splitListFields = "";
var seperateFiled_Values = "";
var grGlide = new GlideRecord("sys_template");
grGlide.addQuery("name",producer.u_template.name);
grGlide.query();
gs.log("get count row"+grGlide.getRowCount());
if(grGlide.next())
{
templateList = grGlide.getValue("template");
}
gs.log("get template value"+templateList);
if(templateList != "")
{
splitListFields = templateList.split("^");
}
gs.log(splitListFields+"get the length "+splitListFields.length);
for(var i=0;i<splitListFields.length;i++);
{
seperateFiled_Values = splitListFields.split("=");
gs.log("get the field "+seperateFiled_Values[0]+"get the value "+seperateFiled_Values[1]);
if(seperateFiled_Values[1] != "")
{
current.seperateFiled_Values[0] = seperateFiled_Values[1];
}
}
here once if i select the template then configuration item and assignment group.should populate into this fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 12:01 AM
Are you able to get the log messages and what value is coming?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 02:01 AM
log message not taking the values it simply returning "get template value" massage without value
gs.log("get template value"+templateList);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 05:17 AM
Take a look at this blog post. Here Im using the applyTemplate() to apply incident templates that were chosen at the call to apply on the created incident.
Using incident templates direct from calls
//Göran

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 06:16 AM
Have a look at the script I posted here: how to remove creation of two same record in the backend in the change request
This does pretty much what you need.