Restrict removal editing of tag

hetaldoctor
Kilo Expert

Hi

We have a requirement to restrict editing of global tags by users

Users will be able to view the tags but should not be able to add or remove global tags

I tried doing this with Business Rules on 'label_entry'

When I click of 'X' for removing tag, it removes it from the display and then when i refresh the page it appears again

Also the message posted on 'delete' is displayed when I refresh the list

Please let me know if you have any ideas around this

Regards

Hetal

1 ACCEPTED SOLUTION

Hi Ankush



I am using $(document).ready but it gave me error



Taking your inputs further I implemented it using below code and it worked



$j(function () {


if(!g_user.hasRole('admin')) {



//code to remove all the delete icon on tags


crossElem = $j('.icon-cross');


map = Array.prototype.map;


map.call(crossElem, function(elem) {


crossElem[elem].remove();


});


}}) ;




Thank you for pointing me to right direction



Regards


Hetal





Hetal Doctor


View solution in original post

3 REPLIES 3

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hello Hetal



The code to add tags is a UI macro which links the tags to the parent table and also create mapping to the table table_entry. Hence creating simple BR on latter will not work. You can either overwrite the macro and restrict the functionality to add/write to few of the users. Or you can write the below code in a Global UI script and call it after pageLoad:


$(document).ready(function(){


if(!g_user.hasRole('admin')) {


        //code to remove addTag option


        $j('#tags_menu')[0].remove();



        //code to remove all the delete icon on tags


        crossElem = $j('#form_tags .icon-cross');


        map = Array.prototype.map;


        map.call(crossElem, function(elem) {


                  crossElem[elem].remove();


                  })


  })


}



I wrote the code with assumption that only admin should have the modification access. Please modify the role as you feel in the line #2.


In either of the scenario, you have to add a global ACL of type list_edit on the field sys_tags (i.e. *.sys_tags) which will only allow the desired users to modify the field from list.


Hi Ankush



I am using $(document).ready but it gave me error



Taking your inputs further I implemented it using below code and it worked



$j(function () {


if(!g_user.hasRole('admin')) {



//code to remove all the delete icon on tags


crossElem = $j('.icon-cross');


map = Array.prototype.map;


map.call(crossElem, function(elem) {


crossElem[elem].remove();


});


}}) ;




Thank you for pointing me to right direction



Regards


Hetal





Hetal Doctor


glad it worked. I miss typed $(document). It should be $j(document).