How to copy the sysid of a template to u_template in a new change request form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2015 02:31 PM
I'm working on a customization and I'm very close, ( I think! ) but there is a roadblock I'd like some help with.
In this post, I'll briefly describe my use case, then I'll (briefly!) describe my implementation and then I'll describe my roadblock.
My use case:
A user opens a new change request form, sets the type to standard and then selects a item from the standard change list and saves the form. Then the user right clicks and selects a menu option to "Apply Template" and the template associated with the standard change list item is applied to the change request.
My implementation:
I have a custom table "Standard Change List Item" which is populated with about 100 items ( and it's growing ).
One field in the "Standard Change List Item" table is u_template, which points to the sys_template table.
When we define a standard change list item, we select a template to be associated with that item.
All this appears to work fine. Now for the Change Request
I added the Template field to the Change Request form, though it does NOT actually display.
On the change_request form, I have an OnChange client script "Apply Standard Change Item" which copies the item's u_template field to the g_form's u_template field. This client script fires anytime the standard change item is changed on the form.
My Road Block is this:
The change request form behaves as if the u_template field is DOES NOT EXIST.
I use alerts in my client script to "Apply Standard Change Item" to show that it runs when a standard change list item is selected.
It displays a nice sysid for the item's template field. But no value has ever been displayed for the change request form's u_template field.
Needless to say, the change request record never receives the sysid of the template in its u_template field.
And so no template is applied to the change request when I click "Apply template".
I'm hoping that there's an obvious solution for this that I'm too close to the forest to see the trees.
References I've checked to date:
http://wiki.servicenow.com/index.php?title=Creating_a_Template
http://www.servicenowguru.com/system-definition/advanced-templates/
Choose template from dropdown?
Thanks in advance for any help you can lend.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2015 02:12 PM
Client Scripts can't access fields that are not displayed on the form (in the client).
You can use GlideAjax to retrieve the field value from the server side. Or you can place the field on the form, then hide it with a UI Policy (the field still gets loaded into the client so can be accessed by Client Scripts).