My Zap workflow reads a new WooCommerce Order and creates a new Xero invoice. I also have an Formatter step between those to add the shipping to the line items. Right now the Account Code for each line item is hard-coded. But I have two different kinds of items. If the sku ends with a D, then the account code for the invoice is 1000, but if it doesn’t end in a D then it is 2000. Shipping is fine left hard-coded.
I’m thinking I need another formatter step before the formatter than deals with the line items. I seems like the formatter would need to do this:
- extract the last character of the SKU (sku is a variable length)
- check if the last character is “D”
- conditionally set the account code to be refenced in the Xero step where the invoice is created
I could run a series of formatters like this:
- A text formatter to get the length of the SKU
- Another text formatter to truncate the sku [ return 1 character, skip length from step 1 above minus 1)
- Another formatter of some kind to assign the value of the Account Code depending on step 2 above results
That seems like a lot of separate steps. What would be the best/most efficient approach to finding the last character and then running a conditional on it?



