Auto-populate Expiration date based on the Start date and Duration of months selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 07:53 AM
Hi All,
Below are the fields on the form level.
Based on the start date and duration of months selected (it is a dropdown of 1 to 12 numbers) - Expiration date should be auto populated.
suppose if the start date is selected as 10-18-2023 and duration of months is selected as 3 months, the Expiration date needs to be auto populated as 10-18-2023 + 90 days.
Can anyone guide me on this.
TIA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 06:38 AM
Hi @Alka_Chaudhary,
The answer is returning null when i kept log and checked in client script. Can you please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 06:43 AM
Hello @Nagashree5 ,
Please provide the screen shot of Client script and script include.
Also, provide the backend names of the following variables-
- POA Start Date
- POA Duration (in months) and choice value of this field.
- POA Expiration Date
Thanks,
Alka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 08:06 PM
Hi @Alka_Chaudhary,
- POA Start Date - poa_start_date
- POA Duration (in months) and choice value of this field. - poa_duration_in_months
- POA Expiration Date - poa_expiration_date
Client Script:
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 11:43 AM
Hello @Nagashree5 ,
Also provide the choices value of variable 'POA Duration (in months) '.
I will provide you the updated the script.
Thanks,
Alka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 07:19 PM - edited 10-19-2023 07:20 PM
Hi @Alka_Chaudhary @Nagashree5 , try the code below(Client Script Only)
This code uses only Javascript Date API to add Months to a Date
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var date_number = getDateFromFormat(g_form.getValue('start_date'), g_user_date_time_format);
var my_date = new Date(date_number)
my_date.setMonth(my_date.getMonth() + 1 + newValue)
g_form.setValue("your_field",my_date.toLocaleDateString())
}
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People