Document ID Field

amol_joshi
Tera Contributor

I have a field with type "Table Name" and another field with type "Document ID".

 

I want to use a script to add another table as a reference in the "Table Name" field and one of the records from that table into the "Document ID" field.

 

I just can't do it.

 

For Example:

 

var gr = new GlideRecord('incidebt');
gr.setLimit(10);
gr.query();

while(gr.next()){
var gr2 = new GlideRecord('u_test_table');
gr2.initialize();
gr2.u_table_field = 'incident';
gr2.u_record_field = gr.getUniqueValue();
gr2.insert();
}
 
Any clues?
1 ACCEPTED SOLUTION

jonsan09
Giga Sage
Giga Sage

The dictionary entry for the needs to have the 'Use dependent field' set to true and have it point to a field on the on your table that has field type set to 'Table Name'

View solution in original post

6 REPLIES 6

Bert_c1
Kilo Patron

Yes, once I changed the dictionary entry for 'u_record_field' as jansan09 says, to use dependent field 'u_table_field', your script worked.

amol_joshi
Tera Contributor

Thank you Jonsan and Bert. The "Use Dependent Field" was the missing link. It worked perfectly. Much appreciated both of you. Thanks again. !