UI Action error: Unchanged ReferenceError: current is not defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 11:06 AM - edited 10-03-2023 11:33 AM
Hi all, I am having trouble with a line of code. Please not this works beautifully on the form but when I try to run ATF, I get the error
Please see code below
Please see error
Anyone know what is causing this and step on how to fix.
Please Note: This is happening on the browser console and not the front end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:26 PM
At Sohi
Is this the correct way
function serverCancelled () {
current.change_state = ChangeState.cancelled
current. state = ChangeState.Cancelled
current.work_end = gs.nowDateTime();
Basically, my goal here is just to update the Actual end date with the current date when I select the cancel change
current. update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:58 PM - edited 10-03-2023 07:15 PM
Hi Cynthia, Servicenow recommends not to use gs.nowDateTime() instead do like below
var gdt = new GlideDateTime();
current.work_end = gdt.getDisplayValue(); // sets current time to field
Reference : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0594666
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 06:57 AM - edited 10-04-2023 07:32 AM
Does not populate the current date and time on the actual end date

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 10:58 PM
Hi @Cynthia19 you need to remove gs.nowDateTime within brackets.
var gdt = new GlideDateTime(); //just pass this with no gs.nowDateTime to get current date time
Harish