Populate planned start and end date through record producer in Project Form(pm_project)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 12:38 AM
Hello Community,
I'm currently creating a record producer for Project(pm_project) and could use some guidance regarding populating planned start and end dates through this.
Here's the situation: I have set up a record producer that enables users to create new projects. Within the record producer I have variables for project name, description, planned start date , planned end date and other relevant information.
Issue : The Planned end date not matching with what was being selected on the Record Producer. It is set to exactly one day after the planned start date by default, and is ignoring the value from record producer. ( I understand that this is handled by OOB client script Calculate End Date From Duration and Calculate Duration From End Date, but still confused on how the record producer value is ignored.)
I would greatly appreciate any insights or experiences you can share, especially if you have encountered similar scenarios.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 08:55 PM
Hi Amritha,
Please request you to share the code to review.
Thanks,
Kailas Bandiwar
- Kailas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 11:42 PM
No codes have been used. Its direct mapping of variable to backend field using 'map to field' option in record producer. I've also made sure that both the variable type and field type is same.
Variable Type : Date/Time
Backend Field type: Date/Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 02:32 AM
Hi Amrita,
Please try using the script to populate date/time field.
var gd = new GlideDateTime();
gd.setValue('Record Producer variable value');
return gd.getDisplayValue();
- Kailas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 01:04 AM - edited 05-09-2023 01:04 AM
Hello KB18,
Thanks for the response,
The script wont help in this case as the planned end date is being set by multiple OOB logic in the backend( Client script and BRs). Tried using an After BR to set the planned end date with setwokflow(false). I guess I'm close to the solution but yet needed to figure out how this can be achieved without impacting other OOB logics implemented .
Cons of using this workaround: current.setworflow(false) prevents the processing of other BR's. This impacts the calculation of duration fields.
Business Rule
When : After
Order 1000
Insert: Checked
(function executeRule(current, previous /*null when async*/ ) {
if (current.variables.planned_end_date) {
current.end_date = current.variables.planned_end_date;
current.approved_end_date = current.variables.planned_end_date;
gs.info("planned end date " + current.variables.planned_end_date);
current.setWorkflow(false);
current.update();
// current.setWorkflow(true);
}
})(current, previous);
Any suggestions are highly appreciated
Thanks,
Amritha