script not working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 07:08 AM
Here I have a list collector type variable. I am getting the values and storing in list. I mentioned below which are not working. Can you help?
var conList = [];
var accList = g_form.getValue('select_buying_agent_account');
var acc = accList.split(',');
flag = 0;
var gr;
for (var i = 0; i < acc.length; i++) {
gr = new GlideRecord('customer_account');
gr.query("sys_id",acc[i]); //NOT working
gr.query();
g_form.addInfoMessage("test");
while (gr.next()) {
g_form.addInfoMessage(gr.name); //Not working
conList.push(gr.name);
}
}
9 REPLIES 9
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 07:13 AM
Hi,
Can you just run this and show what you get in logs
var conList = [];
var accList = g_form.getValue('select_buying_agent_account');
gs.log('accList= '+accList );
var acc = accList.split(',');
flag = 0;
var gr;
gs.log('acc.length= '+acc.length);
for (var i = 0; i < acc.length; i++) {
gs.log('acc[i] '+acc[i]);
gr = new GlideRecord('customer_account');
gr.query("sys_id",acc[i]); //NOT working
gr.query();
g_form.addInfoMessage("test");
while (gr.next()) {
g_form.addInfoMessage(gr.name); //Not working
conList.push(gr.name);
}
}
-Anurag
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 07:23 AM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 08:28 AM
When are you running this? why is it running twice and why are we send the info messages twice?
-Anurag
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 08:29 AM
Also i found the issue, try this
var conList = [];
var accList = g_form.getValue('select_buying_agent_account');
gs.log('accList= '+accList );
var acc = accList.split(',');
flag = 0;
var gr;
gs.log('acc.length= '+acc.length);
for (var i = 0; i < acc.length; i++) {
gs.log('acc[i] '+acc[i]);
gr = new GlideRecord('customer_account');
gr.addQuery("sys_id",acc[i]); //NOT working
gr.query();
g_form.addInfoMessage("test");
while (gr.next()) {
g_form.addInfoMessage(gr.name); //Not working
conList.push(gr.name);
}
}
-Anurag