The CreatorCon Call for Content is officially open! Get started here.

Unable to update multiple records at a time from list view using on cell edit client script

Ksnow
Tera Contributor

Hello @Amit Gujarathi @shloke04 @Ankur Bawiskar 

 

We implemented on change client script for one of the fields on the form to update value based on the another field. Working fine.
Note: Both are reference fields.

The requirement got extended and it was implemented on list view as well using the "on cell edit" client script since on change did not work on list view. And it is also working fine when updating the single record but when updating multiple records at a time from list, it's not working.

Is there any restriction while using on cell edit to update multiple records at a time? If no, please help me to update multiple records at at time from list.

Appreciate your help!

Thanks

 

1 ACCEPTED SOLUTION

@Ksnow ,
Yes this code should work . I have not provided the code for client script as we want a change over list as well as form.
This code will perfectly work at the server end . so whenever the record is updated this field will get auto fill.
Please refer below code for the same.

(function executeRule(current, previous /*null when async*/) {

    // Check if Field 1 (User) is not empty
    if (current.field1) {
        // Get the user record
        var userGr = new GlideRecord('sys_user');
        if (userGr.get(current.field1)) {
            // Set the company in Field 2
            current.field2 = userGr.company;
        }
    }

})(current, previous);

 

 


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

5 REPLIES 5

Danish Bhairag2
Tera Sage

Hi @Ksnow ,

 

Why don't u try an after update Business Rule to set the value.

 

Keep the trigger condition as whenever the value changes of a specific field it should trigger n in advanced set whatever other field u want it to set to.

 

Thanks,

Danish

 

Amit Gujarathi
Giga Sage
Giga Sage

HI @Ksnow ,
I trust you are doing great.
"On Cell Edit" client script is designed to handle cell editing in list views, but it has some limitations when it comes to bulk updating multiple records at once.

For bulk updates, consider using a onBefore Business Rule that runs on update. This server-side script can handle changes made to multiple records, ensuring that your logic is applied consistently, regardless of whether the update is made from the form or the list view.
Please find below sampel code for the same

(function executeRule(current, previous /*null when async*/) {

    // Check if the specific field has been changed
    if (current.your_field_name.changes()) {
    
        current.reference_field_name = some_logic_based_on(current.your_field_name);
    }

})(current, previous);





Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



@Amit Gujarathi Sorry for the late response.

Just to confirm would it be applicable on list or form as well?

Field 1 (reference): Once value/record is selected here.

Field 2 (reference): Auto fill with the value (which is a dependency field in Field1 value)

Example: Field1: User table : once my name is selected, Field2 (company table) to be filled with my company. 

Appreciate your help!

 

Ksnow
Tera Contributor

@Amit Gujarathi Would it be possible to share the script which fits my need? Highly appreciated.

Thanks,

Ksnow