The Zurich release has arrived! Interested in new features and functionalities? Click here for more

In Workflow - Compare field datetime with current system datetime

viigate
Mega Contributor

Hello All,

Here is one thing i am trying to do in my instance i.e in Catalog task when state is changed to On Hold a field appears to input Off Hold Date and at that time a workflow will start which will run till task state is On Hold and till it reaches up the off Hold date.

I tried with timers but somehow the timer is taking up previous set value.

So i tried with wait for condition but now here i am stuck with date comparison in which   i am trying to accomplish that is current system date is equal to Off Hold Date date then make state to "In Progress" else wait.

Below is code part i wrote in workflow script section.

find_real_file.png

Any help regarding this is appreciated. you can also give try at my instance if needed at ServiceNow       with userid & password as - admin. and yes workflow name is "offhold"

Thanks & Regards,

Viraj

4 REPLIES 4

Deepa Srivastav
Kilo Sage

Use current.u_off_hold_date.getDisplayValue() as also log this using gs.log(current.u_off_hold_date.getDisplayValue()) to check it value. I hope this is not variable?




Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy


Ankur Bawiskar
Tera Patron
Tera Patron

Hi,



I have added the timer activity which takes the datetime field. It will wait till the datetime is reached. Kindly test the workflow.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,



I have updated the wait for condition script as well.


You were directly comparing current.somevariable == gs.nowDateTime(). Datetime comparison doesn't work like this. May be what you can do is extract date from datetime and extract date from datetime field on form and then compare the dates.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

RudhraKAM
Tera Guru

did you resolve this ?