FAQ: How can I check that the last characters in a string contain a particular value?

Q: I have a field, SellerSKU, that need to contain a particular value in the last 4 characters of the string. If the record’s field doesn’t contain that value, I want to identify those records, then replace them with another value. How can I do this?

A:
Identify these characters
In your import mapping, use this handlebars expression:

{{substring $.OrderItem.SellerSKU (subtract $.OrderItem[*].SellerSKU.length "4") $.OrderItem[*].SellerSKU.length}}

Note: Make sure you include a space between SellerSKU and ( and again between ) and $.

If you are using NetSuite, you would likely map to Internal ID, a unique number of an item record in NetSuite. However, if your SellerSKU is an item record, use “Items: Item (Name) instead of “Items: Item (Internal Id)”.

The substring command will return the length of your string, then the subtract will remove 4 characters, which will then serve as your starting index. The length command serve as your end index.

Thus, if you had a SellerSKU value of "A99Z-A14-QR-FBA", it would be it would be evaluated as
= "-FBA"

Replace these characters

To replace these characters, you would use replace instead of subtract in the equation above:

replace $.OrderItem[*].SellerSKU "-FBA" ""