Can I add a record to sys_dictionary by using a script?

erantal2000
Giga Contributor

Hi everyone,

I am trying to create a script that will automatically add field to a table.

Is there a way I can do this? maybe by adding a record to sys_dictionary?

I tried to do that by using GlideRecord but it didn't work.

Any ideas?

1 ACCEPTED SOLUTION

I just created my own app and scoped table. WHen I executed it on scoped app, it gave me cross-scope-privilege error.

I executed it in Global scope and it worked.


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

14 REPLIES 14

You are not supposed to use the sys id. you should use the name of the scope. For ex for Global, application name is 'global'.

Below is also a custom app and scope name is x_123622.....

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.

Still, not working 😞 

 

var r = new GlideRecord('sys_dictionary');
r.initialize();
r.active = 'true';
r.internal_type = 'string';
r.name = 'x_77594_my_table';
r.column_label = 'Field 1';
r.element = 'field1';
r.max_length = 40;
r.table_reference = 'false';
r.sys_scope = 'x_77594_my_scope';
r.insert();

 

Record not created...

Are you running this script on the same Scope 'x_77594_my_scope'? That is Do you have the application set to scoped app and not Global.

Do you see an error in system log? DId you try running it from Background script


Please mark this response as correct or helpful if it assisted you with your question.

1. Yes, I am running it from the same scope 🙂

2. I am running it from an on demand scheduled job. I add gs.info in the beginning of the script and in the end of the script. I see the output of both gs.info scripts in the log, but other than that - nothing. No errors, no other logs. And the record is not created...

I removed few things. Can you give one more try.

 

var r = new GlideRecord('sys_dictionary');
r.initialize();
r.internal_type = 'string';
r.name = 'x_77594_my_table';
r.column_label = 'Field 1';
r.sys_scope = 'x_77594_my_scope';
r.insert();


Please mark this response as correct or helpful if it assisted you with your question.