Auto Populate Actual Date with current date

Ponda
Tera Contributor

Hi 

 

How can I auto populate the actual end date field on the change form upon selecting the cancel change button

 

In other words, I did like for that to auto populate with current date when I select cancel change to cancel the change request

And I want to make this button only visible in the implement state and only visible to change implementers

Ponda_0-1695678573076.png

 

1 ACCEPTED SOLUTION

_William_Knight
Kilo Guru

This worked for me 

current.work_end = gs.nowDateTime();

current.update();

View solution in original post

9 REPLIES 9

RAMANA MURTHY G
Mega Sage
Mega Sage

Hello @Ponda ,

You can modify your Cancel Change UI action

in the condition field you can write as 

 

current.state == -1 && gs.hasRole('you_change_implementer_role');    // your change implementer role here
                                                                                                                    // state -1 will represents Implement state

 

 

to set the actual end date, you can implement the below code in your UI action server-side script

 

var todayDate = new GlideDateTime();
current.work_end = todayDate;           // work_end is the backend name of actual end date

 

 

Please mark my answer correct & helpful, if it helps you

Thank you

 

 

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

to set the actual end date, you can implement the below code in your UI action server-side script does now work, what am I doing wrong 

Please see screenshot

Ponda_0-1695736475918.png

 

 

@Ponda 

in line number 14, you need to give space between new and GlideDateTime()

it should be like

var todayDate = new GlideDateTime();

 

Please mark my answer correct & helpful, if it helps you

Thank you

 

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

I corrected that slight error but still not successful, looks like the code does nothing 

 

Ponda_0-1695781269611.png