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

onCellEdit client script

Mustafeez
Tera Contributor

Hi folks,

 

If admin user is logged in only he can edit the list not other user how can I solve this problem use of onCellEdit client script?

 

Thanks,

Mustafeez.

4 REPLIES 4

James Chun
Kilo Patron

Hi @Mustafeez,

 

Are you saying only the Admin should be able to modify the records in the list view?

If so, do you have to use the onCellEdit client script? 

There are multiple ways to do this:

I believe the 1st and last options will apply even to the admins. So ACL might be the best way for you.

 

Cheers

Harish KM
Kilo Patron
Kilo Patron

Hi @Mustafeez

OnCellEdit client script can be used for only one single field to restrict in list layout.

 

if you want to lock all field then list_edit acl will do,

create a read acl on tablename.* like below

 

HarishKM_0-1711072216176.pngHarishKM_1-1711072254396.png

 

Regards
Harish

SK Chand Basha
Tera Sage

Hi @Mustafeez  On cell edit is applicable only for particular field if you wants to apply all the fields use ACL or List Control

You can disable list editing using List Controls.  To do this:

1. Right-click on a column in the list view.  Select Configure > List Control.

2. In the List Control, change the List edit type to Disable list editing.

I Hope this helps and mark Helpful!

 

 

Maddysunil
Kilo Sage

@Mustafeez 

Client script:

 

function onCellEdit(fieldName, oldValue, newValue, field, rowSysId, displayValue) {
    // Check if the logged-in user is an admin
    if (!g_user.hasRole('admin')) {
        // If not admin, prevent the edit
        alert("You do not have permission to edit this list.");
        return false; // Prevent edit
    }
    // Allow edit if the user is an admin
    return true;
}

 

Additionally, perform a server-side check to enforce security. Even if the client script is bypassed, this server-side check will prevent unauthorized edits. you can create ACL or before update business rule

BR:

 

if (!gs.hasRole('admin')) {
        // If not admin, prevent the update
        gs.addErrorMessage("You do not have permission to edit this list.");
        current.setAbortAction(true); // Cancel the update
    }

 

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

 

Thanks