- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2014 06:21 AM
Morning guys,
We have a button on our change form that takes our change back to an editable phase (if a client needs to change dates after approval etc) We want to have a confirm message pop up on clicking that button that warns the user that the change will need to be re approved, they then click yes to continue. We have a similar script in incident under a client script that warns the user if someone else has over written the ticket since they opened it and do they want to overwrite that update. I am assuming the script is not working as its been written for use in a client script not a UI Action. the script is below.
function onSubmit() {
confirm(getMessage("Please note this will require the change to go back through the approval process."));
}
current.phase = "In Definition";
current.u_backed_out = "true";
current.u_cab_approved = "false";
action.setRedirectURL(current);
current.update();
Any thoughts?
Solved! Go to Solution.
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2014 01:46 PM
Hi David,
Try putting the following script in your UI Action:
//Client-side 'onclick' function
function changeToEdit(){ // this is function called on the "onClick" field
if(confirm(getMessage("Please note this will require the change to go back through the approval process."))){
// run Server Action
gsftSubmit(null, g_form.getFormElement(), 'changeToEditAction'); // this refers to the "Action name"
}
else{
return false; // cancel action if confirm response is false/cancel
}
}
//Code that runs without 'onclick'
if(typeof window == 'undefined')
runPricingBusRuleCode(); // call Server code
//Server-side
function runPricingBusRuleCode(){
current.phase = "In Definition";
current.u_backed_out = "true";
current.u_cab_approved = "false";
action.setRedirectURL(current);
}
Note that this script refers to the current UI Action as having an "Action Name" of changeToEditAction, and an "onClick" function name of changeToEdit().
Regards,
Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2014 01:21 AM
Thank you very much for the help. this is almost working. The prompt does display however it still requires any mandatory fields to be populated, at the point of clicking this button the use is moving the change back so the mandatory fields should be ignored (somehow)
Any thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2014 01:33 AM
Hi Steve,
To skip the mandatory fields, add this line just before line number 5 in the above code from Jake
g_form.checkMandatory = false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2014 02:22 AM
Hi all.
thanks for the help, this now appears to be working as hoped. I have giving Jake a correct answer due to providing the script I requested as I hadn't mentioned the mandatory fields at that point. thanks to Anurag for providing the last piece needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2014 03:22 AM
Hi,
Any idea how I would addapt your warning script to work in the below UI Action? This one is to warn users that if they fail the validation check any unsaved data will be lost, this should prompt them to check their dates. I have tried putting it at the very top and just before the fields are set near the bottom (amending the warning) The warning pops up but clicking yes take you back to the change list and an error of not authorized. Any thoughts?
var scr = new SetChangeRisk();
scr.setRisk(current);
if ((!current.start_date.nil()) && (!current.end_date.nil())) {
if (current.start_date > current.end_date) {
gs.addErrorMessage('Work Start date must be before Work End date');
current.setAbortAction(true);
}
}
if ((!current.start_date.nil()) && (!current.end_date.nil())) {
if (current.start_date < current.u_change_window_start) {
gs.addErrorMessage('Work Start date must be within the change window');
current.setAbortAction(true);
}
}
if ((!current.start_date.nil()) && (!current.end_date.nil())) {
if (current.u_change_window_start > current.u_change_window_end) {
gs.addErrorMessage('Work Start date must be within the change window');
current.setAbortAction(true);
}
}
if ((!current.start_date.nil()) && (!current.end_date.nil())) {
if (current.u_change_window_end < current.end_date) {
gs.addErrorMessage('Work Start date must be within the change window');
current.setAbortAction(true);
}
}
gs.log ("message check dates" + current.start_date + " " + gs.now());
if(calcLeadTime(current.u_change_window_start, new GlideDateTime()) < 7*24*60*60 && current.impact == '1') {
current.setAbortAction(true);
gs.addInfoMessage("The planned start date must be more than 7 business days in the future.");
}
else {
current.phase = "Waiting Technical Review";
current.u_backed_out = false;
current.update();
action.setRedirectURL(current);
}
function calcLeadTime(start,begin){
var dc = new DurationCalculator();
dc.setSchedule('8bf030aa88e24100c7e84b85c4739fa4',"");
return(dc.calcScheduleDuration(begin,start,true));
}