Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to get the value from the result of querying databaseView

KS18
Giga Guru

I have tried the following method but it does not work.

 

 var databaseView = 'x_xxxxxxxxxxxxxx';
 var databaseViewRecords = new GlideRecord(databaseView);
databaseViewRecords.query();
var rows = databaseViewRecords.getRowCount();
var list = [];
for (var i = 0; i < rows; i++) {
 pidList.push(databaseViewRecords[i].getValue('sys_id'));
}

 

error:

com.glide.script.RhinoEcmaError: The undefined value has no properties.




 

1 ACCEPTED SOLUTION

kamlesh kjmar
Mega Sage

Hi @KS18 ,

 

Please use the below script, it should work

 

 

 var databaseView = 'x_xxxxxxxxxxxxxx';
 var databaseViewRecords = new GlideRecord(databaseView);
databaseViewRecords.query();
//var rows = databaseViewRecords.getRowCount();
var list = [];
while (databaseViewRecords.next()){
 list.push(databaseViewRecords.getValue('sys_id'));  //All sys_id will be pushed to 'list' array
}

 

 

NOTE : Please note that Database view in actual is not a table, hence you would find it's sys_id little bit strange. It's not like any other table's 32 character long sys_id.

 

 

I hope this help.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh

View solution in original post

1 REPLY 1

kamlesh kjmar
Mega Sage

Hi @KS18 ,

 

Please use the below script, it should work

 

 

 var databaseView = 'x_xxxxxxxxxxxxxx';
 var databaseViewRecords = new GlideRecord(databaseView);
databaseViewRecords.query();
//var rows = databaseViewRecords.getRowCount();
var list = [];
while (databaseViewRecords.next()){
 list.push(databaseViewRecords.getValue('sys_id'));  //All sys_id will be pushed to 'list' array
}

 

 

NOTE : Please note that Database view in actual is not a table, hence you would find it's sys_id little bit strange. It's not like any other table's 32 character long sys_id.

 

 

I hope this help.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh