- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 06:50 AM
Hi all, as a requirement I am trying to create a datasource that allows, given a specific template, to create new fields on a table in a scoped application.
everything works correctly except the type, whatever sys_id representing a field type I go to put, it does not populate the type and remains empty.
I have tried both from simple mapping and from script, but the result remains the same.
Below you can find a test performed in dev instance on the incident table:
var gr = new GlideRecord("sys_dictionary");
gr.initialize();
gr.name = "incident";
gr.internal_type = "aab367c1bf3320001875647fcf073909"; //sys_id of integer on sys_glide_object table
gr.column_label = "test field";
gr.element = "u_test_field";
gr.insert();
here the result:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 07:21 AM
new GlideDBUtil.createElement('incident', 'Scripted field', 'u_scripted_field', 'string', '', 'incident', true);
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 07:24 AM
try it like this
gr.internal_type = 'integer'
//for integer type
OR
gr.internal_type = 'string'
//for string type
OR
gr.internal_type = 'reference'
//for reference type
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 07:21 AM
Hi
I tried below script it works absolutely fine, tested in background script:
var tbl = new GlideRecord('sys_dictionary');
tbl.name = 'incident';
tbl.type = 'string';
tbl.column_label ='TEST';
tbl.element = 'test';
tbl.insert();
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 07:27 AM
please try to change the type to "integer" you'll see that the type will be string because it is not working but instead is putting "string" type as default value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 07:34 AM
Hi
Worked for me:
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 07:27 AM
Hi,
You can use this to create a reference type field.
GlideDBUtil.createElement("incident", "customField","u_customField", 'reference', '', "Incident", true);