Updated Worknotes visibility for specific group

MansiT
Tera Contributor

I have a requirement that a specific group can only see the worknotes in activity logs which has been added by their group not by other groups, How can I implement this, any suggestions?

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@MansiT 

try to create field level READ ACL on work_notes and use script to control the visibility

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

Ankur Bawiskar
Tera Patron
Tera Patron

@MansiT 

something like this in field level READ ACL with advanced script

// get logged in users group
var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());

// get the members for those groups
var groupMembersArr = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", 'IN', groups.toString());
gr.query();
while (gr.next()) {
    groupMembersArr.push(gr.user.user_id.toString());
}

// check if work notes is added by any 1 member of the group to which logged in user belongs
var journalRec = new GlideRecord("sys_journal_field");
journalRec.addEncodedQuery("element=work_notes^element_id=" + current.getUniqueValue());
journalRec.addQuery('sys_created_by', 'IN', groupMembersArr.toString());
journalRec.setLimit(1);
journalRec.query();
answer = journalRec.hasNext();

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

@MansiT 

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

PritamG
Mega Guru

create a custom business rule on the Task table. and use condition 

if(current.work_notes && current.getValue('group') !== gs.getUser().getGroupName()){

     current.work_notes = '';

}

then, create ACL on work_notes.

set conditions to allow access only if the user's group matches the group of the worknote. use script include or client script a script to filter worknotes dynamically on form load or save