- 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 01:16 AM
Hi Gaurav,
can you try using update multiple record action
Please mark helpful and correct if it resolves your issue.
Regards,
Ayush
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 01:44 AM
Hello Ayush,
"Update multiple records" This option is updating the current records end date instead of the previous records end date. Any further suggestions.!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 02:41 AM
Hi Gaurav,
what are you passing in the record field?
if 'update Record' updates only the first record and if you want to update multiple records while passing the previous record in the record field, you might have to use for each loop to access all the previous records.
- 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