
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 09:51 AM
Update 8/7:
I had to re-do the script because i was running into issues with the split. When someone used ':' to end their intro to the issue, it would not let them submit. It was also messing with older stories. So this is what I have now but I cannot understand why this will not let me submit at all now. Even when all of the fields are filled in.
function onSubmit () {
var req_keys = [
'Instance(s):',
'Record(s) used:',
'Impacted user group(s):',
'Logged in user to view/create issue:',
'Steps to reproduce:'
];
var array = [];
var desc = g_form.getValue('description');
for (var i = 0; i < req_keys.length; i++); {
if (desc.indexOf(array, req_keys[i]) > -1) {
alert('Please include all template fields in your description:\n\nInstance(s) ->\nRecord(s) used ->\nImpacted user group(s) ->\nLogged in user to view/create issue ->\nSteps to reproduce ->');
return false;
}
}
}
____________________________________________________________________________________________________________________________________________________
Hi,
I need to check to see if the "description" field has been changed when a user logs and incident. I have 4 fields within the description field that are mandatory to complete before the record can be submitted. I am running into issues trying to figure out how to check if the description field has been filled out completely. I have tried to compare the empty value to the filled value but then i cant submit the form. Any help would be appreciated!
See screen shots below:
Here is the client script I currently have:
function onSubmit() {
var description = g_form.getValue('u_description');
g_form.getValue('u_description');
//Type appropriate comment here, and begin script below
if ( description == 'Instance: +
'\n' + 'Record used:'
'\n' + 'Impacted user group:'
'\n' + 'Steps to reproduce:'); {
alert('Please fill out all description requirements and attach screenshots');
return false;
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 10:34 AM
Please check if this helps.
function onSubmit() {
var i;
var description = g_form.getValue('u_description');
var dec_text = description.split('\n');
for(i = 0; i < dec_text.length; i++){
var description_text = dec_text[i].split(':');
if(description_text[1] == ""){
alert('Please fill out all description requirements and attach screenshots');
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 10:04 AM
There could be simpler way of doing this but i always used string functions for this. Something like below.
var desc = g_form.getValue('description');
var instance = desc.substring(desc.indexOf('Instance:')+9, desc.indexOf('Record used:')).trim() ; //9 bz length of 'Instance:'
alert(instance) ;
var recordUsed= desc.substring(desc.indexOf('Record used:')+12, desc.indexOf('Record used:')).trim() ; //12 bz length of 'Record used:'
alert(recordUsed) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 10:08 AM
Hi Casey,
I would suggest to create 4 separate fields to achieve this. With the separate fields, you have more control on validation.
Having all 4 fields in a single text field would make the maintenance and reporting really complex.
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 10:25 AM
I would like to do that as well but the requirements dont allow for more fields - they just want the description field to be more clear.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 10:34 AM
Please check if this helps.
function onSubmit() {
var i;
var description = g_form.getValue('u_description');
var dec_text = description.split('\n');
for(i = 0; i < dec_text.length; i++){
var description_text = dec_text[i].split(':');
if(description_text[1] == ""){
alert('Please fill out all description requirements and attach screenshots');
return false;
}
}
}