Templates in GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 06:59 AM
Hi,
Just wondering if anyone can please help out with my GlideRecord problem?
I've not had a lot of experience with GlideRecord so hopefully this is quite simple, I'm basically trying to use a script to add the template's
Short Description and Description to the form's Short Description and Description respectively if a template has been selected from a dropdown list.
It populates them when you click submit, so that's ok. I was just looking to add the descriptions to the fields to help the user while
they are filling out the form.
I seem to be hitting a problem finding a match with the Sys_ID of the template in the dropdown list and the Sys_ID in the Template table.
I'm assuming this is possible as the Sys_ID appears to be available in the Template table.
Am I doing something silly that's not registering a match with the Templates? (code below as a screenshot , it would not let me upload as text...)
many thanks for your help,
Richard,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 07:33 AM
I assume you are trying to apply the "Template" values in the template correct? If so you need to use the applyTemplate() function. So assuming your template selection box has the SysID as the value, all you need is this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
applyTemplate(newvalue);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 10:15 AM
Hi Michael,
Thank you very much for getting back to me, I was looking to fill in the Short Description and the Description on the form with the Short Description of the Template currently selected in 'Search Common Issues' dropdown, it was to show the user the details of the template they have selected.
As it stands at the moment the two fields are mandatory and require an input, the user types in something then the template details overwrite this on pressing submit button.
I was hoping to populate them in the form pre-submission,
thanks again for looking,
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 11:03 AM
Richard, I am still confused. The Template (sys_template) table has a short_description field but no description so I am not clear on what you want to capture from those records. Templates are typically used by setting the Template fields with data you wish to place into a record. There you can set the Short Description, Description and many other fields. Maybe a screenshot of what you are trying to do will help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 02:17 AM
Hi Michael,
Thanks for your help, but we're not trying to apply the template in a standard manner. Templates are working, but applied after submission.
However, from the serviceportal we have a search which applies templates on common issues. in those templates we have fields such as "description". we also have a description in the user portal.
Now when a user selects an issue that has a template, what we would like to do, prior to submission is glidequery the matching template so that we can pull information of what "will" be applied, prior to applying it.
For two reasons
1. To inform the user that selecting a template in the search has done something positive and not seem like a waste of tehir time as applying after submission the end user would remain unaware the search has benefited him.
2. We could place in the template common questions like "Please provide batch number" without having to create a bespoke form for that issue and a one size fits all form.
so the way it usually works is
1. search identifies a common issue which we have a template.
2. user puts in description
3. submission
4. template is applied and description is appended
how we want to work is
1. search identifies a common issue which we have a template.
2. template is applied client side prior to submission
3. user adds more to the description
4. submission
So in short, the problem we have ran into is that the search as a reference field ran against templates, returns a sysID, we thought we could glidequery, clientside that "newValue" sysID against the sys_template table and get the fields we want. however sys_template does not seem to identify the sysID and we get 0 results...that confuses me.
Thanks again for your help,
Richard