Auto populate fields

Thalavai m
Tera Contributor

Hi 

We want to Auto populate RTO and RPO field value in business application form.  but it should populate before saving the form, we tried with business rule and flow but its populating after saving the form, both are mandatory field, please help us regarding this. 

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

You'll want to use a Client Script for this onLoad or onChange of a field, then you will see the fields populate on the form.

nitinsharma2510
Giga Guru

Hi Thalavai,

 

You need to set the values on client side using Client Script/ UI Policy which would run onLoad or onChange. If the user is saving the form manually post the calculation, you can ignore any server-side script like BR or flow, if not you can still keep the backend script active.

 

Thanks, 

Nitin

Aniket Chavan
Tera Sage
Tera Sage

Hello @Thalavai m ,

To instantly populate field values on the form, consider using a UI Policy or an onChange Client Script. These are ideal for updating fields in real time, as they work immediately after changes are made, unlike Business Rules or Flows that trigger upon saving.

Give this a try, and let me know if you encounter any issues while setting it up.

 

Here's an example of an onChange client script that you can customize to fit your needs:

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

    // Replace 'your_field' with the actual field that triggers the changes
    g_form.setValue('rto', 'value_for_rto');
    g_form.setValue('rpo', 'value_for_rpo');
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.


Regards,
Aniket

 

aryanjain25
Giga Guru

Hi @Thalavai m ,

To auto-populate the RTO and RPO fields before saving the form in the Business Application form, you’ll need to use a Client Script, as those execute on the server side after the record is saved.

 

Here is a sample code:

 

(function executeRule(current, g_form, g_user, g_scratchpad) {
    // This will run when the form loads
    if (g_form.isNewRecord()) {
        // Logic to auto-populate the RTO and RPO fields
        var rtoValue = 'your_calculated_value_for_RTO'; // replace with your logic
        var rpoValue = 'your_calculated_value_for_RPO'; // replace with your logic
        
        // Set the values
        g_form.setValue('rto_field_name', rtoValue);
        g_form.setValue('rpo_field_name', rpoValue);
    }
})(current, g_form, g_user, g_scratchpad);

 

 

I would appreciate if you can mark this response as correct or helpful if it assisted you with your question.

 

Thanks,

Aryan Jain