How to get value in array?

Sid_Takali
Kilo Patron
Kilo Patron

Hi all,

I have a requirement where I have to get a Phone Number and, Alternative Phone 1, Alternative Phone 2 field values in Array. How can I define an array[] to get the values from consumer table. 

 

1 ACCEPTED SOLUTION

kunal20
Kilo Guru

Hi Siddharam,

You can use the following code to push the data in an array and I have also created one separate array so You can display the data easily.

 

var consumerData = new GlideRecord('csm_consumer');
consumerData.query();
consumerData.setLimit(5);
var consumers = [];
while(consumerData.next()){
    var tempArray = []
        tempArray.push(consumerData .getValue('number') + '');
        tempArray.push(consumerData .getValue('mobile_phone') + ''); 
        consumers.push(tempArray); 
}
gs.info(consumers[0])

Kindly mark this as helpful.

Thank You,

Kunal

View solution in original post

6 REPLIES 6

Sid_Takali
Kilo Patron
Kilo Patron

How do I push Phone Number and, Alternative Phone 1, Alternative Phone 2 field values in Array.

kindly mark the answer as correct if it helped you.

Thanks

kunal20
Kilo Guru

Hi Siddharam,

You can use the following code to push the data in an array and I have also created one separate array so You can display the data easily.

 

var consumerData = new GlideRecord('csm_consumer');
consumerData.query();
consumerData.setLimit(5);
var consumers = [];
while(consumerData.next()){
    var tempArray = []
        tempArray.push(consumerData .getValue('number') + '');
        tempArray.push(consumerData .getValue('mobile_phone') + ''); 
        consumers.push(tempArray); 
}
gs.info(consumers[0])

Kindly mark this as helpful.

Thank You,

Kunal

Hi Kunal, 

How can I assign the values stored in array to a choice field?