In Workflow - Compare field datetime with current system datetime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 10:04 AM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 10:35 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 11:58 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 12:01 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2018 01:02 PM
did you resolve this ?