Background script to replace sys id for multiple record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 08:26 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 08:57 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 09:17 PM
How many query i can define. I need to update more than 1000 records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 09:31 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 10:08 PM
There is no specific criteria. Like just the name is same thats it but with diff sys id