Auto populate fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 08:51 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 10:15 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 12:24 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 12:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 12:47 AM
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