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

AMIT SHISHODIA2
Giga Guru

Hi both of you,I am working on record producer.
I have written a script include for this.

The data type of 5 variables is reference.
All the work is same but I have to change table name every time so,I have created 5 functions 
So,I want that table name to be dynamically used so that I can use one function instead of one

code:

var FaFEMethods = Class.create();
FaFEMethods.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFaFEMethods: function(requested_for, project) {

var userIds = [];
gs.addInfoMessage(project);
var gr = new GlideRecord('u_project');
if (requested_for == '') {
userIds = userIds.join(',');
return "sys_idIN" + userIds;
} else {
var gr1 = new GlideRecord('core_country');
gr1.query();
while (gr1.next()) {
if (gr1.name == requested_for) {
gr.addQuery('u_country', gr1.sys_id);
gr.query();
while (gr.next()) {
userIds.push(gr.getValue('sys_id'));
}

userIds = userIds.join(',');
return "sys_idIN" + userIds;
}
}

}


},

type: 'FaFEMethods'
});

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.