- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-07-2020 07:30 AM
Hi,
This article is about making fields Mandatory for Templates. I have seen many use cases where we want some of the fields to be mandatory before you save the template so that a record which has mandatory fields on the form level should not have empty values while creation. Following example is about making short description mandatory for incident table while creating a new template for incident and as the short description is mandatory on INC form so while creation of template aslo you must hve short description selected in the template itself.
and if you have short description field choosed on the template you must have values inside it. Those are the 2 checks i have put on. Hope it helps out for all of you.
Client script Code
function onSubmit() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('table')=='incident')
{
var ex =g_form.getValue('sys_template.template');
alert(ex);
if(ex.indexOf('short_description')>-1)
{
var p=ex.indexOf('short_description');
var app= ex.indexOf('^',p+18);
var w=ex.slice(p,p+18);
alert("^"+app);
alert(w);
alert(p+18);
if(app==p+18)
{
alert('empty');
g_form.addErrorMessage('Please fill in the short description');
return false;
}
else
{
alert('String present');
}
}
else
if(ex.indexOf('short_description')==-1)
{
g_form.addErrorMessage('Please select the short description');
return false;
}
}
}
Thanks All,
Abinash