Setting a Date Time in the Resolved field using Workflow

wilson8
Kilo Contributor

Hi, I am a relative newbie to this so we are trying to set a value of the resolved date of an incident by workflow along with some other textual values for resolution information etc.

In workflow editor we go to the set value screen and use the drop down to select the Resolved field where we have entered the expression "javascript:gs.nowDateTime()". I have just been checking on some incidents and it appears not be working consistently if at all. The workflow has run and got beyond this action (usually then to terminate).


I have trawled the wiki but found nothing to confirm or otherwise that this is the correct or best way of doing this I would appreciate any advice.

Many thanks in advance..

1 ACCEPTED SOLUTION

Hi Wilson,



You can use 'Set Values' activity in your workflow to set all the values.


Example-


In the 'Set Values' activity in your workflow you can use below-


Set -


Resolved - javascript:gs.nowDateTime()


Resolved By - javascript:gs.getUserID()


and so on.



Thanks,


Tanaji


View solution in original post

13 REPLIES 13

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Wilson,



You mean it is working for few tickets and not for others. Please confirm.


wilson8
Kilo Contributor

Hi Pradeep



I have foound an example of 2 incidents using the same workflow and one has a resolved date and the other has not. The one that does not have a resolved date was actually updated later than the other ticket so if the previous ticket worked so should a later one (I would think).


wilson8
Kilo Contributor

I think I amy have figured this out now. The workflow you modify does not update any currently running workflows, it will only come into play on workflow initiated after the update.This would explain why I am seeing some incidents with resolved dates and some without. The important date is actually the start date of the workflow relative to when the workflow was updated.



We also need to update the Resolved by field so for the record we are using the following


Resolved:                       javascript:gs.nowDateTime()


Resolved By:         javascript:gs.getUserID()



Theere are a few other fields to populate such as Cloure Summary, Closure Notes and a couple of fields for the resolution categorization (2 levels). The State must of course be set to Resolved.



Thanks for anyone taking a look but I believe this explains my issue.


Hello Wilson,



Use the advanced option and write a script in the activity :



current.resolved=gs.nowDateTime();


current.resolved_by=gs.getUserID();



Hope, this will resolve your issue.



Thanks,


Subhankar