How to send the dynamic table name of the table selected

AMIT SHISHODIA2
Giga Guru

There are 5 variables on record producer which are depend on requested_for.
I want to pass the table name of those 5 tables dynamically in script include.
If I will select first variable,GlideRecord will work on first table.If I select Second table GlideRecord will work on second table for all 5 variables.

1 ACCEPTED SOLUTION

AMIT SHISHODIA2
Giga Guru

Got the Solution:
1.We can simply pass table name inside '' from every variable advance reference qualifier

OR 

2.We can make system property having value table name and can pass system property in advance reference qualifier.

View solution in original post

21 REPLIES 21

Actually it is a custom table(to which variable referring) having no parent table.
now,I can't edit parent table because table is created

Hi Amit,

So 5 variables are referring to 5 different custom tables?

line of code suggested by Pradeep should still give you the table name by dot walking to sys_class_name

Can you try to submit the record producer and then query the target record and print the value of the table from scripts background for that variable

var gr = new GlideRecord('table_name');

gr.get('record_sys_id');

var tableName = gr.variables.<variableName>.sys_class_name;

gs.info(tableName);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

But Sir,what will I get after submitting record producer?
I need to do it before submitting record producer

It is showing the table name of the variable referring to the table having parent table not for all tables 

Hi Amit,

just want to check whether you are able to get table name from the variable once record is created and value is present

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes Sir,It is showing the table name of the variable referring to the table having parent table not for all tables means there is also variables which are referring to a custom table which has no parent table