Better solution for a nested IF... but I can't think of one

Options

I am working through many many modules and removing 'bad' data or process and have come across a nested If formula, and cannot think of a better way to replace it.
Have a module with 2 sources MATERIAL and LABEL TYPE.
Within the material list we have several labels (FRONT, REAR, DECAL + 6 others)
In the module i need to show the label code for the appropriate label.

So i have a formula in the line item LABELCODE

If ITEM(Label Type) = Label Type.Front then Material.Front Label ELSE

If ITEM(Label Type) = Label Type.Rear then Material.Rear Label ELSE

If ITEM(Label Type) = Label Type.Decal then Material.Decal Label…

and then onwards for all 9 label types

This works perfectly but makes my eye twitch as it's not the best approach…

Two issues, one is the nested loop and the other is hard coding of label types, but I cannot think of a tidy solution?

Thanks

Answers

  • Dikshant
    Options

    Create a system module for Label type and store this Label type to Material mapping. Populate the mapping and and refer it directly.

  • Dikshant
    Options

  • DeveloperCYT
    edited May 8
    Options

    Each material has 7 labels, so would i need to map 7 line items in the material list?
    Sorry for some reason this one is just baffling me…