Populate form field value based on variable value using Flow designer script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 05:14 AM
Hello,
We have a requirement to populate value in the Due date field (Form field) based on value available in the variable field(date/time). It should set Due date to be after 5 days of variable value. This should be achieved using flow designer.
We tried using following script but it's not working. Please help us to correct it.
var disableDate = fd_data.trigger.request_item.variables.variable_name;
var days = 5;
//assuming there are 8 business hours
days = days*8;
var dur = new GlideDuration(60 * 60 * 1000 * days);
var schedule = new GlideSchedule('0aa442ea6fbc92006e652091be3ee48e'); //put your schedule sys_id here
var end = schedule.add(disableDate, dur);
return end;
Regards,
Jainil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 05:31 AM
@Community Alums Please refer to this thread https://www.servicenow.com/community/developer-forum/trying-to-set-a-due-date-in-flow-designer-to-a-dynamic-date-of-7/m-p/2829113 it answers the same question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 08:52 AM
@Sandeep Rajput We tried replicating the similar script but it displays error:
Here is the script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 09:00 AM
@Community Alums Could you please share the details on the error you are seeing?