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

michaelmassey
Giga Contributor

Hi Wilson,



You really should not use current.update() in a workflow. See:


http://wiki.servicenow.com/index.php?title=Workflow_Validator_-_ValidateScriptForCurrentDotUpdate#gs...



Why wouldn't you use Business Rules? There are mark_resolved and mark_closed OOB Business rules on Incident table. You could use those as a starter point and customize your own from those.



Thanks,


Michael


wilson8
Kilo Contributor

Hi Michael and thanks for your input.



I was not aware that you should not use current.update in workflow so that was an interesting read!


It is not my workflow although it appeared to bea reasonable way of going about things. To use business rules we probably want to invoke them (if possible) from the workflow as there are several directions from which the Resolve action can be approached but definitely worth a look, especially if they include all the actions that should take place when an incident is resolved.


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


This would be lot easier to configure as well as maintain.


Hope this helps you


wilson8
Kilo Contributor

Thank you Tanaji



This is what we have in fact or at least what we are proposing to go ahead with. I am just a little concerned now about Michael's thoughts expressed above. Does using



Resolved - javascript:gs.nowDateTime()


Resolved By - javascript:gs.getUserID()



count as current.update()   -   if not then I guess we are OK to go ahead



Thanks



Wilson