The Zurich release has arrived! Interested in new features and functionalities? Click here for more

I have a requirement like if existing end date is auto populated based on the Gid selection,I need t

pdisrilatha
Tera Contributor

I have a requirement like if existing end date is auto populated based on the Gid selection, I need to add 1 day to the existing end date and populate that date in New field called New start date.

Please suggest thanks in advance.

pdisrilatha_1-1727284702113.png

 

 

 

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@pdisrilatha Please check if the following script works for you.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    // Get the date from the field (assuming it's in yyyy-MM-dd format)
    var originalDate = new Date(newValue);

    // Add one day (24 hours * 60 minutes * 60 seconds * 1000 milliseconds)
    originalDate.setDate(originalDate.getDate() + 1);

    // Format the date back to yyyy-MM-dd
    var dd = String(originalDate.getDate()).padStart(2, '0');
    var mm = String(originalDate.getMonth() + 1).padStart(2, '0'); // January is 0!
    var yyyy = originalDate.getFullYear();

    var newDate = yyyy + '-' + mm + '-' + dd;

    // Set the new date back to the field
    g_form.setValue('your_date_field', newDate);
}

View solution in original post

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@pdisrilatha Please check if the following script works for you.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    // Get the date from the field (assuming it's in yyyy-MM-dd format)
    var originalDate = new Date(newValue);

    // Add one day (24 hours * 60 minutes * 60 seconds * 1000 milliseconds)
    originalDate.setDate(originalDate.getDate() + 1);

    // Format the date back to yyyy-MM-dd
    var dd = String(originalDate.getDate()).padStart(2, '0');
    var mm = String(originalDate.getMonth() + 1).padStart(2, '0'); // January is 0!
    var yyyy = originalDate.getFullYear();

    var newDate = yyyy + '-' + mm + '-' + dd;

    // Set the new date back to the field
    g_form.setValue('your_date_field', newDate);
}

@Sandeep Rajput 

Thanks, it is really help full to me

HI @Sandeep Rajput 

I need help in portal if you have any idea, please look into another post their requirement is clear mentioned.