Update Historical List Data in a Background Script

Elizabeth26
Tera Contributor

I normally update historical data in background scripts when necessary.

However, this one is not working as I'd like.

 

I have an old field which was a list field. I have multiple random combinations of values.

I want to move the data into a new table and new field which is now a singular choice.

 

I am trying to grab the singles first where I can but I can't get the singles to appear in a query even if I filter to just show "retaliation" I get all the combos that include it as well. Here is the query x_letter_claims!=NULL^x_letter_claims=Retaliation

 

I was hoping to use a background script like I've normally done but if I can't get the query to come up I am not sure what to do? 

 

For example: I am getting retaliation, gender, disability or retaliation, gender or retaliation. I have many variations and combos and I am not sure what to do. I thought I'd first just try updating the ones that are singular but I can't even get that query to work. 

 

var grAll = new GlideRecord('x_table');

 

grAll.addEncodedQuery('x_letter_claims!=NULL^x_letter_claims=Retaliation');

grAll.query();

 

while(grAll.next()) {

grAll.x_claims = 'Retaliation';

grAll.autoSysFields(false);

grAll.setWorkflow(false);

grAll.update();

 

}

1 ACCEPTED SOLUTION

Try adding a condition for does not contain comma:

NiaMcCash_0-1674579020930.png

 

View solution in original post

12 REPLIES 12

The problem is it shows all kinds of combinations (see screenshot)

Nia McCash
Mega Sage
Mega Sage

Can you provide some screenshots or any more info on this? Looks like you are working with a custom table so without any more information, it's difficult to help. 

It is a custom table but it's the way these list/multi-select fields work that's causing the issue. (see screenshot)

Your screenshot shows that you are filtering for *keyword but you haven't shown us the filter that results, like this: 

NiaMcCash_0-1674576455039.png

 

The * is a wildcard which means you're searching for values that CONTAIN the keyword. That's not the same as EQUALS keyword.

 

Perhaps you can also tell us more about what kind of field x_letter_claims is. Can you provide the sys_dictionary details for it?

When I right click on the list view to - show matching I get the "=" but it still shows the combinations rather than just the singular "retaliation" 

The field is a list and it's so hard to work with. This why I am trying to get all of the data out of this field and move it to a choice list instead. 

 

I just can't figure out how to get the data to show up in a way that I can write a script to map it to a new choice list.