Create template through UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2014 02:54 AM
Hi All
How i can create template thought UI Action( Create template) on incident form, i got help from SNCGURU( » Advanced Templates) . it's really helpful but my requirement is different.
what i need.
Suppose you are opening existing record on incident and you want to create new template so you personalize form and clicking on Template Option-> Save as template,
Example.
Same thing i want to create through UI Action
Means make custom UI Action and same functionality use as Save as template.
Please help if you have any idea,and let me know.
Thanks
C.K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2014 05:27 AM
ServiceNow templates store all field-value pairs that need to be applied to the target record in the Template field in the form of an encoded query which is basically a sting like this:
active=true^priority=1^category=incident
You can create a UI action that will:
- read field values from the current record
- build an encoded query similar to the one above
- insert a new record into Templates [sys_template] table using GlideRecord API
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2014 12:49 PM
Hi C.K.
Here is an example UI action I started for change in case you are still stuck:
CreateChangeTemplate();
function CreateChangeTemplate() {
var temp = new GlideRecord('sys_template');
var ci = current.cmdb_ci;
var assgroup = current.assignment_group;
var cat = current.cateogry;
var shortd = current.short_description;
var reason = current.u_reason_for_change;
temp.initialize();
temp.table = ('change_request');
temp.template = 'cmdb_ci=' + ci + '^assignment_group=' + assgroup + '^category=' + cat + '^short_description=' + shortd + '^u_reason_for_change=' + reason;
temp.insert();
}