Difference between u_tags and sys_tags

akash89
Giga Contributor

What is the difference between "u_tags" and "sys_tags"?
How do I tag a record with u_tag?

5 REPLIES 5

Brian Dailey1
Kilo Sage

Hi Akash,



Are you referring to the prefixes "u_" and "sys_" that appear on some field names?   If so, the answer is simple...



  • "u_" gets prefixed to the names of custom tables and fields created by the user (you)
    (everything you create)
  • "sys_" indicates a system field or table... (e.g., sys_created_by, sys_created_on, [sys_email], [sys_properties], etc.)
    (base system, these cannot be created by you)


You will see all the basic "sys_" fields get added for you after you save a new custom table, everything else you add gets prefixed with "u_" to indicate a user customization.



An exception to this are variables... when you create variables for the catalog/etc., their names will not be prefixed as above, but appear exactly as you named them.




Hope that helps.



Thanks,


-Brian


Dear Brian,



The information is definitely helpful.



Though my question was more on the tagging feature available in ServiceNow where the user can go and tag any task.


This tag can be a newly created one or any existing one from the system.



One can tag any item by opening the form and clicking the Edit tag option available at the top (or) by right clicking on any task record


in the Catalog Tasks list and choosing the 'Assign tag' option.



Users can also decide to make this tag's view to only themselves / to limited number of people / to everyone.


By default it is only viewed by the user.



Now, one can add Tag columns in your catalog tasks list from the Personalize options.


There you can notice that two different options are available - Tags(u_tags) & Tags(sys_tags).



At first I thought that custom tags created by users will be marked under u_tags whereas the ones available by default in the system will be


marked as sys_tags.


But I observed that in both cases, the tags show up in the sys_tags option. Not even the having different user level restriction has any impact on a tag


moving from sys to u.



So finally, here's my question again - What can I do or what kind of tag do I need to create, so that it gets categorized as u_tags &


when I add the column in my catalog tasks list, it shows up under Tags(u_tags)?



Thanks,


Akash.


I'm starting to explore Tags as well. Here is what I can tell you in a general sense.



If you want to create a Tag that can be leveraged across the platform, go to System Definition|Tags and create one with all the particular visibility controls you want around it. Then you can Tag a record and it will show up as a sys_tag. This is not a column on the table. It is special.



If you want to query the table for records with a particular sys_tag, you need to know the sys_tag's sys_id and you can do something like the following:


gr = new GlideRecord('sys_user');


gr.addQuery('sys_tags.efc668c6130c66003f61db128144b0db', '=', 'efc668c6130c66003f61db128144b0db');


gr.query();


gs.print(gr.getRowCount());



You might be interested in searching for rows without the Tag:


gr = new GlideRecord('sys_user');


gr.addNullQuery('sys_tags.efc668c6130c66003f61db128144b0db');


gr.query();


gs.print(gr.getRowCount());



Both are pretty powerful and useful.



You mention u_tags. I am assuming you have created a custom column on your table called Tags. To populate this field, you would need to expose it on your Form or use scripting. It will not allow you to leverage the standard "Tagging" functions.



The addition of a u_tags column is still very useful in some cases. We added a u_meta_tags field to our cmdb_ci table that allows us to add common aliases to CIs for the purposes of searching in a Reference picker.


Hi Brian,



Thanks for your contribution on tagging.       How would you go about adding a tag programmatically?       I have experimented with a couple of different syntaxes and nothing works



Doesn't work:


var gr = new GlideRecord("incident");


if(gr.get('number', 'INC0220237')){


  gr.sys_tags.e2e3fb3f13a826805f6d5fc96144b0e7 = 'e2e3fb3f13a826805f6d5fc96144b0e7';


  gr.update();


}



Doesn't work:


var gr = new GlideRecord("incident");


if(gr.get('number', 'INC0220237')){


    gr.setValue('sys_tags.e2e3fb3f13a826805f6d5fc96144b0e7', 'e2e3fb3f13a826805f6d5fc96144b0e7');


    gr.update();


}



Doesn't work:


var gr = new GlideRecord("incident");


if(gr.get('number', 'INC0220237')){


    gr.setValue('sys_tags', 'e2e3fb3f13a826805f6d5fc96144b0e7');


    gr.update();


}




Thanks in advance,



Trey Carroll