- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 09:24 AM - edited 10-04-2023 09:31 AM
I am having issues with a line of code and assistance is highly appreciated
I modified cancel change UI and I added line of code
current.work_end = gs.nowDateTime();
current.update();
This code is just to update the actual end date with current date/time. Code works like a charm but cause the above error when setting up ATF and also in the browser console
Followed recommendation from
UI Action error: Unchanged ReferenceError: current... - Page 2 - ServiceNow Community
Hoewever, this does not work. The date is not populating
Doing a background script to check the code, I get the below error
evaluator: com.glide.script.RhinoEcmaError: Cannot set property "work_end" of null to "2023-10-04 09:01:43" script : Line(1) column(0) ==> 1: current.work_end = gs.nowDateTime(); 2: current.update();
I cannot seem to figure this one out. Please help!!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 10:24 AM
Hi Shawna,
There are a number of replies on the post you referenced, but none of them marked as correct yet, so which one(s) did you try? Where did you add the line(s) of code? My OOB Cancel Change UI Action already contains a current.update(); line, so you shouldn't need to add another one. Does it work if you add the current.work_end line inside the setRedirect() function before the existing current.update()? If not, you'll need a line first to call the Action name like this:
var changeConfirmCancelDialog;
function setChangeCancelState() {
g_form.setValue("state", "4");
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'state_model_move_to_canceled'); //MUST call the 'Action name' set in this UI Action
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.work_end = gs.nowDateTime();
current.update();
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 10:24 AM
Hi Shawna,
There are a number of replies on the post you referenced, but none of them marked as correct yet, so which one(s) did you try? Where did you add the line(s) of code? My OOB Cancel Change UI Action already contains a current.update(); line, so you shouldn't need to add another one. Does it work if you add the current.work_end line inside the setRedirect() function before the existing current.update()? If not, you'll need a line first to call the Action name like this:
var changeConfirmCancelDialog;
function setChangeCancelState() {
g_form.setValue("state", "4");
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'state_model_move_to_canceled'); //MUST call the 'Action name' set in this UI Action
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.work_end = gs.nowDateTime();
current.update();
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 12:19 PM
Work Brad, I am still scratching my head how I missed that existing current. update();
I appreciate your help on this one.
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 12:30 PM