How to make fields read only on "Update All" / "Update Selected"

Harshal Aditya
Mega Sage
Mega Sage

Hi Experts,

 

Could you please help me making the fields of Update ALL/Update selected form read only using Client script or UI policy.

As we do not want user to update particular fields using bulk update functionality.

 

Thanks in advance 

 

 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @Harshal Aditya ,
How about this.

create a new view and remove the field that you don't want the users to edit and update the "Update all" and "Update selected" context menu (sys_ui_context_menu) and put the force the users to be new view by setting 

sysparm_view to new view that's created.

 

Regards,
Chaitanya

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Harshal Aditya 

 

Not 100% sure, but did you try oncell edit client script?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Juhi Poddar
Kilo Patron

Hello @Harshal Aditya 

You can try this code in client script:

function onLoad() {
   //Type appropriate comment here, and begin script below
   if (g_form.getTableName() === 'sys_user') { //update table name 
        // List of fields to restrict
        var restrictedFields = ['first_name', 'last_name', 'email']; //update field names

        // Loop through restricted fields and make them read-only
        restrictedFields.forEach(function (field) {
            g_form.setReadOnly(field, true);
        });
    }
}

"If you found my answer helpful, please give like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

 

 

Hi @Juhi Poddar - Thanks for the update. Client script and UI policy are not working on the update all/update selected form.

Is there any way we can enable it

Chaitanya ILCR
Kilo Patron

Hi @Harshal Aditya ,
How about this.

create a new view and remove the field that you don't want the users to edit and update the "Update all" and "Update selected" context menu (sys_ui_context_menu) and put the force the users to be new view by setting 

sysparm_view to new view that's created.

 

Regards,
Chaitanya