The CreatorCon Call for Content is officially open! Get started here.

Custom Field with no "u_" Prefix

Bradford Shelle
Kilo Guru

More for curiosity than anything, but has anyone ever created a custom field on a table, then stripped out the "u_" that the system puts in place to denote that the field was user generated?

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

If you could find a way to do so, I would advise against doing it. On the next upgrade, that field could get over written by mistake because it doesn't start with a 'u'.


View solution in original post

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

I agree with Michael here, it is not recommended. This way you will find diffcult to differentiate between system n custom tables.


Bradford Shelle
Kilo Guru

Okay. I won't bother looking into it more since it sounds like it can create more problems than it will solve.



Thanks for the responses everyone!


jijoesam
Mega Contributor

I understand we may foresee few issues in the future after upgrades if we have custom fields without prefix 'u_'.


But if we create them as a part of a import set table otherwise any independent table, I am not sure how far an upgrade can impact.


If you still want to proceed, You can use the following script and run it from background or Fix Scripts.



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////


var attrs = new Packages.java.util.HashMap();


var fieldName = 'Name of the field';


var ca = new GlideColumnAttributes(fieldName);


ca.setType('string');


ca.setUsePrefix(false); // If you set this to TRUE, 'u_' will be added as prefix


attrs.put(fieldName, ca);



var tc = new GlideTableCreator('Table Name', 'Table Label');


tc.setColumnAttributes(attrs);


tc.update();


Thanks for the solution. This worked quite well!!

Field is created but there is no way I could edit this field values now like type, length, label etc as it is now behaving as a system field.

Being an admin-still it is showing as insufficient rights to delete a field which I created as you mentioned.

Could you please help how could I update the field values or delete this field completely?