Update Multiple records using list collector

DEV976
Tera Expert

Hi Community,
Good Day!

There is a catalog item have a list collector type and links with Hardware [alm_hardware] and I want to update it's state. if I select one record, it updates the record of the table. But if I select multiple records, these are not updating on Hardware. I want to update multiple records at one time.

this is the list collector:

DEV976_0-1688759591476.png

this is BR on table:
var gr=new GlideRecord('alm_hardware');
gr.addQuery('sys_id',current.variables.show_asset_tag);
gr.query();
if(gr.next()){
gr.install_status=current.variables.state;
gr.update();
}

1 ACCEPTED SOLUTION

@DEV976 

Oh sorry got it !! we are doing (if(gr.next)) we need to do like this(while(gr.next()))

Please try this :-

var gr=new GlideRecord('alm_hardware');
gr.addQuery('sys_id', 'IN', current.variables.show_asset_tag);
gr.query();
while(gr.next()){
gr.install_status=current.variables.state;
gr.update();
}

 

if not work then try by replacing 'sys_id' with 'display_name'.

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

Regards,

Ranjit Nimbalkar

View solution in original post

7 REPLIES 7

Ranjit Nimbalka
Mega Sage

Hi @DEV976 

Try this script:-

var gr=new GlideRecord('alm_hardware');
gr.addQuery('sys_id', 'IN', current.variables.show_asset_tag);
gr.query();
if(gr.next()){
gr.install_status=current.variables.state;
gr.update();
}

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

Regards,

Ranjit Nimbalkar

Hi @Ranjit Nimbalk, thanks for your reply but it is not working

 

Hi @DEV976 

Please try this :-

var gr=new GlideRecord('alm_hardware');
gr.addQuery('display_name', 'IN', current.variables.show_asset_tag);
gr.query();
if(gr.next()){
gr.install_status=current.variables.state;
gr.update();
}

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

Regards,

Ranjit Nimbalkar

Hi @Ranjit Nimbalka, i've try this one too, but the result is same