Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

@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

thanks, @Ranjit Nimbalka, it works!!!!!!!

kamal Kishore1
Tera Contributor

Hi Dear - Can you please share all the steps you followed to set up Service Catalog for multiple asset update using list collector to set retired status.

I would like to replicate same for CI update? I would really appreciate you help!