The CreatorCon Call for Content is officially open! Get started here.

Run fix script only on translated version

Diogo Luz
Tera Expert

Hi all,

 

Recently, I've found out that we've a typo in the description of several catalog items (they all contain a specific word in the name). The typo only occurs in the translated version (our instances only have two versions, dutch and english, and in english there's nothing to change). I've tried to run the following fix script but it doesn't seem to work. 

 

var records = new GlideRecord('sc_cat_item');
records.addQuery('name', 'CONTAINS', 'this word');
records.query();
while (records.next()) {
    var name = records.getValue('name');
    var description = records.getValue('description');
    var updatedDescription = description.replace('this', 'that');
    records.setValue('description', updatedDescription);
    records.update();
}

 What am I doing wrong?

 

Thanks in advance 🙂

6 REPLIES 6

I've tried that script with the right inputs, it identifies all necessary items to change but proceeds to not do any real change, the typo is still there.

I will take a look at the link you provided, look really useful.

Did you notice the error in my script? You will need to update the 'value' field, not the 'description' field:

        // Replace "this" with "that"
        var updatedDescription = description.replace('this', 'that');
        records.setValue('value', updatedDescription);
        records.update();