- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2023 10:40 PM
Hello Everyone
Requirement:
Working on Multi row variable set on a record producer. When try to create a new contribution record, based on the Start date of the current record it should update the end date of the previous record. We are using Flow designer, as this entire functionality is working on approval process. As soon the request is approved, it should update the end date of previous record.
For example, please check the below screenshots.
Present situation:
At present, it is updating only for first record. However, it should work for every record.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 01:39 AM
Hello @Gaurav Gupta3
To achieve your goal of updating the end date of the previous record in a Multi-Row Variable Set on a record producer when creating a new contribution record, you need to identify the previous record and update its end date based on the start date of the current record.
var currentStartDate = inputs['current_record.start_date']; // Adjust the field name based on your actual field name
var previousEndDate = inputs['previous_record.end_date']; // Adjust the field name based on your actual field name
if (currentStartDate && previousEndDate) {
var newEndDate = new GlideDateTime(currentStartDate);
newEndDate.addDaysUTC(-1);
outputs['updated_end_date'] = newEndDate.getLocalDate();
} else {
outputs['updated_end_date'] = null; // Handle the case where either the current start date or previous end date is not available
}
In this script:
- inputs['current_record.start_date'] represents the start date of the current record.
- inputs['previous_record.end_date'] represents the end date of the previous record.
Make sure to adjust the field names based on your actual field names.
If the start date of the current record and the end date of the previous record are available, it calculates the new end date by subtracting one day from the current start date. The result is then stored in outputs['updated_end_date'].
Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Thanks & Regards,
Kartik Magadum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 02:26 AM
Hi Kartik,
Where you want me to apply this logic, in Update records section or you want me to create a new Action.
Also this logic, I didnt understand
if (currentStartDate && previousEndDate)
This seems to be incomplete without any condition. Who is marking this helpful, I didnt get it.
Regards
Gaurav Gupta