- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2019 08:22 AM
Hi all
In a UI Action "Resolve Incident", I would like that when clicking on the "Resolve incident" button, I would like the message below to appear if the mandatory fields are not filled:
Here is the script of the UI Action "Resolve Incident":
function resolveIncident(){
//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
if (!jQuery('.is-required').length){
alert("Veuillez remplir les champs obligatoires");
}
else
{g_form.setValue('incident_state', 6);
g_form.setValue('state', 6);
//if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
//try {g_form.hideFieldMsg('comments');} catch(e) {}
//g_form.setMandatory('comments', true);
//g_form.showFieldMsg('comments','Comments are required when resolving an Incident','error');
//return false; //Abort submission
//}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //MUST call the 'Action name' set in this UI Action
}
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
function serverResolve(){
gs.log("A Test save");
current.incident_state = 6;
current.state = 6;
current.update();
}
Thanks for your help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2019 08:37 AM
Hi ,
You can use code like below
if(current.state == 6)
{
var notes = g_form.getValue('close_notes'); // put the correct field name in getValue
var code = g_form.getValue('close_codes');
if(notes.length != 0 || code.length != 0)
{
g_form.addErrorMessage('The close notes and close codes are mandatory while resolving incident');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2019 08:37 AM
Hi ,
You can use code like below
if(current.state == 6)
{
var notes = g_form.getValue('close_notes'); // put the correct field name in getValue
var code = g_form.getValue('close_codes');
if(notes.length != 0 || code.length != 0)
{
g_form.addErrorMessage('The close notes and close codes are mandatory while resolving incident');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2019 01:58 AM
Hi
Thank you so much for your reply
But when I apply this script, When I click on the button "resolve incident" the field "Incident state" takes the value 6.
I would like this field to keep its initial value and not to take the value 6
Thank you for your help
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2019 01:58 AM
Here is the script:
function resolveIncident(){
var notes = g_form.getValue('close_notes'); // put the correct field name in getValue
var code = g_form.getValue('close_codes');
var Istate= g_form.getValue('incident_state');
var state= g_form.getValue('state');
if(notes.length != 0 || code.length != 0)
{
g_form.addErrorMessage('The close notes and close codes are mandatory while resolving incident');
g_form.setValue('incident_state', Istate);
g_form.setValue('state', state);
return false;
}
else {
{g_form.setValue('incident_state', 6);
g_form.setValue('state', 6);
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //MUST call the 'Action name' set in this UI Action
}
}
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
function serverResolve(){
gs.log("A Test save");
current.incident_state = 6;
current.state = 6;
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2019 01:47 AM
Hi
Thank you so much for your reply
But when I apply this script, When I click on the button "resolve incident" the field "Incident state" takes the value 6.
I would like this field to keep its initial value and not to take the value 6
Thank you for your help
Best regards