Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

UI Action error: Unchanged ReferenceError: current is not defined

Malo
Tera Contributor

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

Malo_0-1696356208663.png

Please see error 

Malo_1-1696356355242.png

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 

8 REPLIES 8

Cynthia19
Tera Contributor

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();

}

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

Regards
Harish

Does not populate the current date and time on the actual end date 

 

Cynthia19_0-1696429916959.png

 

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

Regards
Harish