Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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
Tera 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

DrewW
Mega Sage

Well in your script I'm going to guess that incidebt should have been incident and you need to fix that.

 

amol_joshi
Tera Contributor

Thanks for that Drew, I realised it after I pasted it and I fixed it as well. Now I can get the field with "Table Name" data type accurately pointing to the "incident" table but I can not get the other field with "Document ID" data type to populate with a record from the Incident table. Please help.

I want to see something like "Incident: INC000225522" in the "Document ID" type field. Thanks.

Bert_c1
Kilo Patron

Hi amol_joshi,

 

I don't see any problem with your script, I am guessing that 'u_record_field' on  the 'u_test_table' table is defined as a Reference field for the 'incident' table.  If so, I expect your script to work.  But then that field on u_test_table will show the number field from the incident table, and not "Incident: INC000225522" on the u_test_table form.

 

I now see your defined it as a Document ID field, and that will require more work. I don't use that field type.

jonsan09
Tera 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'