How to get a template to fire in a record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 02:41 AM
Hi, I have a story requirement for a record producer, where I have to add a new choice to a question and then once that new choice is selected an incident is created. In the incident some fields are auto-populated like urgency, impact etc. This is done by creating a template.
So I have created a template with all the requirements setting urgency, impact etc to the values needed. I have added a new choice in the question and I have also created an incident catalog template with the new template but when I fill out the record producer and select the new choice, the template that gets fired is another one...what can I do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 04:06 AM
There are a few ways to apply a template on a record producer. First is under the "Generated Record Data" tab as there's a template available -> but it always applies.
You can also specify in the script section what template to apply by saying "current.applyTemplate("template_name");
In your case it might already have the Generated Record Data template defined or one in the script.
Either way you can add something like this at the bottom
if (producer.variables.<question_field_name> == <"new choice value">){
current.applyTemplate("template_name");
}else{
current.applyTemplate("old_template_name");
}
If the old template was specified on the record producers field, you can just remove it and mention it in the else condition, so that you'll either use the new template for the new choice or the old one for any other selection.
It's also possible that there's a BR that triggers a template, but usually it would be on the RP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 04:30 AM
Hi, thanks for the help, but I forgot to mention that there are lots of templates.
For every choice in that question, there seems to be a different template. There is not much variation between the templates but they all have different names and short descriptions. So if it was just 1 template I could have added it on 'Generated record data' tab. At the moment this is in the script box of the record producer
var olfr = new OLFRUtils(); current.u_asset = producer.user_asset_id; current.description = olfr.generateDescription('PEGA Application Fault', producer); current.caller_id = gs.getUserID();
current.u_template = olfr.applyTemplate(current, producer);
if(producer.customer_complaint == 'Yes'){
current.u_customer_complaints = true;
} else {
current.u_customer_complaints = false;
}
I think the highlighted line refers to the template application, but its generic and doesn't specify any template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 12:52 AM
Looks like they've set it up so that a script include is used to handle the templates used.
From the navigation search script includes and in there you should find a script include called "OLFRUtils". It has a function called applyTemplate which takes the current record and the record producer (the form you're filling) as parameters.
I bet that in the function it is deciding which template to use so you'll just need to add your condition into the mix.