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

Hardware Asset Workspace

kalpeshjath
Tera Contributor

Hi All,

Requirement : 

I want only specific attributes to be editable for certain user group on alm_hardware table. The attributes which i want to be editable are 'install_status', 'substatus', 'assigned_to', 'asset_function', 'work_notes'. Apart from this attributes rest all attributes should be greyed out and not editable. The users are updating the details of assets from Hardware Asset Workspace - Asset Estate - Hardware Assets. 

 

Please can someone help me on the same and let me know if this can be done. As I tried a lot but not able to figure out how can i do it. 

13 REPLIES 13

@kalpeshjath 

on form you can write onLoad client script on alm_hardware table and Display business rule

something like this

Display Business Rule

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

    // Check if the current user belongs to the specific user group
    var userGR = new GlideRecord('sys_user_grmember');
    userGR.addQuery('user', gs.getUserID());
    userGR.addQuery('group.name', 'YOUR_USER_GROUP_NAME'); // Replace with your user group name
    userGR.query(); 
    g_scratchpad.isEditableUser = userGR.hasNext();
})(current, previous);

Client Script:

function onLoad() {
    // Check if the user is in the specific user group
    if (g_scratchpad.isEditableUser) {
        // Make specific fields editable
        g_form.setReadOnly('install_status', false);
        g_form.setReadOnly('substatus', false);
        g_form.setReadOnly('assigned_to', false);
        g_form.setReadOnly('asset_function', false);
        g_form.setReadOnly('work_notes', false);

        // Make all other fields read-only
        var fields = g_form.getEditableFields();
        for (var i = 0; i < fields.length; i++) {
            if (['install_status', 'substatus', 'assigned_to', 'asset_function', 'work_notes'].indexOf(fields[i]) === -1) {
                g_form.setReadOnly(fields[i], true);
            }
        }
    } else {
        // Make all fields read-only for users not in the specific group
        var allFields = g_form.getEditableFields();
        for (var j = 0; j < allFields.length; j++) {
            g_form.setReadOnly(allFields[j], true);
        }
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@kalpeshjath 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@kalpeshjath 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

NinjaGriller
Tera Contributor

I am noticing the limited Attribute updates allowable from the workspace view as well.  Seems HAM Admin should be able to update any attribute from the Table view in Workspace.

How to do that?