ACL ? for Time Worked

markdart
Kilo Guru

I am trying to allow the Role timecard_admin access to edit other users Time Worked but finding the whole form set read only after they have created them. I have set write access on ACL for the whole form. I have the applied role working so they can create Time worked on Case Record for other users but they can edit after. there is a client script that does set some fields read only on load and even after deactivating they cant edit. 

1 ACCEPTED SOLUTION

I think I solved it by doing this instead of the wildcard , would this then take presendence over the other policy ?

markdart_0-1754543186564.png

 

View solution in original post

6 REPLIES 6

markdart
Kilo Guru

Client script OnLoad ReadOnly & Mandatory Fields

function onLoad() {
    var category = g_form.getValue('category');
    var task = g_form.getValue('task');
    var user = g_form.getValue('user');

    // Only run logic if the 'category' field exists on the form
    if (!g_form.hasField('category')) {
        return;
    }

    // Make 'user' field read-only for everyone except those with the 'timecard_admin' role
    if (!g_user.hasRole('timecard_admin')) {
        g_form.setReadOnly('user', true);
    }

    // Make 'work_date' field mandatory
    g_form.setMandatory('work_date', true);

    // Make 'task' field read-only if it has a value
    if (task) {
        g_form.setReadOnly('task', true);
    }

    // Default 'user' to current user if not already set
    if (!user) {
        g_form.setValue('user', g_user.userID);
    }

    // Default 'category' to 'task_work' if not already set
    if (!category) {
        g_form.setValue('category', 'task_work');
    }
}

markdart
Kilo Guru
 

markdart
Kilo Guru
 

Ankur Bawiskar
Tera Patron
Tera Patron

@markdart 

so what's the challenge?

what's not working? what debugging did you do?

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