below script is not working properly please check and let me know my mistake

mani55
Tera Contributor

i am trying to set one value is empty and i tried below script but still not working please check and help me anyone with my mistake

var test1 = new GlideRecord('alm_hardware');
    test1.get('u_premium_service.u_number='+ritm.variables.hardware_asset^asset_tag!=ritm.variables.hardware_asset^ORasset_tag=NULL');

    //remove PREMxxxx01 from hardware asset table
    test1.u_premium_service = "";


    test1.update();
1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this

 

var test1 = new GlideRecord('alm_hardware');
test1.addEncodedQuery('u_premium_service.u_number='+ritm.variables.hardware_asset+'^asset_tag!='+ritm.variables.hardware_asset+'^ORasset_tag=NULL');
test1.query();
while(test1.next()) //use if if you are expecting only 1 record to be returned
    //remove PREMxxxx01 from hardware asset table
    test1.u_premium_service = "";
    test1.update();
}

 

-Anurag

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this

 

var test1 = new GlideRecord('alm_hardware');
test1.addEncodedQuery('u_premium_service.u_number='+ritm.variables.hardware_asset+'^asset_tag!='+ritm.variables.hardware_asset+'^ORasset_tag=NULL');
test1.query();
while(test1.next()) //use if if you are expecting only 1 record to be returned
    //remove PREMxxxx01 from hardware asset table
    test1.u_premium_service = "";
    test1.update();
}

 

-Anurag

Ankur Bawiskar
Tera Patron
Tera Patron

@mani55 

your query is wrong.

form the correct query with correct fields and the operators i.e. AND, OR

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@mani55 

what is stored in that variable hardware_asset?

you are comparing it against asset_tag field and also against u_premium_service.u_number

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader