After scanning the community I noticed I wasn't the only one missing this and gave it a shoot to try and do this as my first own "bigger" development.
And here is the result and feel free to use it for your own. I have made it to fit the OOB version of how you create incident, but it can easily be tweaked into your version(hopefully). We are on Fuji, but it is also tested on Geneva as well. Most of the knowledge I used for this I found here:
Advanced Templates
Preferable is to just copy the OOB-rules etc. and edit that and inactive the OOB ones to still get the future upgrades on the originals ones in case you want to see what is new etc.. Here I'm just editing the real ones.
Solution:
1. Create a reference field on call named "Incident template". When you create it you can choose any field you want since the template-table isn't in the choice list. This because some tables is system tables are excluded from showing up on the choice list. You can either edit the property: glide.ui.permitted_tables and add the sys_template or do as I suggest here.
- Choose Configure dictionary on the field "incident template".
- Change the reference field to the template table (sys_template).
- Add the ref qual condition "Table IS incident" to just see incident templates.
Now we have a field on call that is named "incident template" and is visible the whole time. So lets hide it unless the call type is "Incident".
2. Create an UI Policy so that the field "incident template" only shows if the call type is incident.
- Set the condition to "Call type IS incident".
- Make sure the "reverse if false" is checked.
- Make UI Policy Action on field "u_incident_template" and set "visible to true".
Now, the last thing to do with call is to make sure it applies the value when creating the incident.
3. Edit the business rule "CallTypedChanged"
- Add the following line: gr.u_incident_template = current.u_incident_template;
Now everything is done with Call. Let's head over to incident.
Do the same first step as we did with call. We'll make it exact the same if we want to build some more functionality later on it.
4. Create a reference field on call named "Incident template". When you create it you can choose any field you want since the template-table isn't in the choice list. This because some tables is system tables are excluded from showing up on the choice list. You can either edit the property: glide.ui.permitted_tables and add the sys_template or do as I suggest here.
- Choose Configure dictionary on the field "incident template".
- Change the reference field to the template table (sys_template).
- Add the ref qual condition "Table IS incident" to just see incident templates.
5. Create an UI policy that hides the field "incident template".
- No condition since we never want the field to be visible. But we still need it in the form to be able to change it etc.
- Make a UI Policy Action on field "u_incident_template". and set visible to false.
And finally lets apply the template on the incident while its loading.
6. Create a onLoad script that will apply the template when the incident is loading. Efter its applyed it will empty the incident template field otherwise it will apply every time the incident is loaded.
- Add the following code:
{
//Get the value from the field.
var template = g_form.getValue('u_incident_template');
if(template != '')
{
//Apply the template
applyTemplate(template);
//Wait 2 seconds before clearing the value with the function clearTemplate
setTimeout(clearTemplate,2000);
}
}
function clearTemplate()
{//Empty the field
g_form.setValue('u_incident_template', '');
}
Now it should be working like a charm. Let me know if got something on your mind about it, perahaps it's some new functionality for it?
Inga kommentarer:
Skicka en kommentar