Background script to replace sys id for multiple record

Kunal33
Tera Expert

Hi Team 

 

i need to change value of product type in service offering table for multiple record but value is not same for all record.

for eg:-  suppose i have 30 service offering(30 is just a random number) , for 1st 10 , value is already as A but now A is made inactive and we have created another record A with diff sys id.. so we need to replace sys ids. 

4 REPLIES 4

Tai Vu
Kilo Patron
Kilo Patron

Hi @Kunal33 

It's better to define a function and you can call it as many as you'd like to.

Sample below.

var encoded_query_1 = '<your_offering_encoded_query_1>';
var product_type_1 = '<your_product_type_1>';
updateOfferingProduct(encoded_query_1, product_type_1);
var encoded_query_2 = '<your_offering_encoded_query_2>';
var product_type_2 = '<your_product_type_2>';
updateOfferingProduct(encoded_query_2, product_type_2);
//more...

function updateOfferingProduct(encoded_query, product_type){
    var grOffering = new GlideRecord('service_offering');
    grOffering.addEncodedQuery(encoded_query);
    grOffering.query();
    grOffering.setValue('<your_product_type_fied>', product_type);
    grOffering.updateMultiple();
}

 

Cheers,

Tai Vu

How many query i can define. I need to update more than 1000 records

Hi @Kunal33 

Are there specific criteria or conditions for updating the Product Type of the Offerings? For instance, if you're changing Product Type A for 10 records of Offering, how can we determine which Product Type should be updated for each specific Offering?

There is no specific criteria. Like just the name is same thats it but with diff sys id