how to get field values using g_list in ui action and passed through confirm message

kranthikumar_a
Kilo Contributor

Hi Firends,

                                  I have created one ui action as a list choice and in that i used a g_listChecked(). By using this i get the how many selected list records i checked an alert in that it is showing of sys_id's of selected records. Based on that sys_id's i want to get the task number and pass to a confirm message. How it can be please help me as soon as possible.

Regards,

Kranthi.

5 REPLIES 5

saiiaskumar
Mega Guru

This code will help to get to know selected records data - Number.

 

function listRecords(){
try{
var numArray = [],tableName = g_list.getTableName(),listIds = g_list.getChecked();
if(!listIds)
return;
if(!tableName)
return;
var gr = new GlideRecord(tableName);
gr.query();
while(gr.next()){
if(listIds.indexOf(gr.sys_id)>"-1")
numArray.push(gr.number);
}
if(numArray){
var ans = confirm("Do you want to delete these records - "+numArray+"?");
if(ans ==true){
deleteRecords(tableName,numArray);
}else
return;
}
}catch(e){
alert("Error is : "+e);
}
}

function deleteRecords(tableName,numArray){
try{
var count = 0;
var gr = new GlideRecord(tableName);
gr.query();
while(gr.next()){
if(numArray.toString().indexOf(gr.number)>"-1"){
gr.deleteRecord();
count++;
}
}
if(count == numArray.length){
setTimeout(function(){
location.reload();
},1000);
}
}catch(e){
alert("Error is : "+e);
}
}