Skip to main content

We are using a GI to pull an inventory sheet and one of the columns has a name of Class for the grouping of items with specific INItemClass.ItemCLassCD such as 001-01-01, or 002-06-01. Items beginning with numbers such as 001, 002, 003, or 006 should show up as Class Items A or 010- - as ‘Other’ or 010-0- as Other. My SWITCH looks like this:

=SWITCH(LEFT(LINItemClass.ItemClassCD],3) = 001 OR LEFT(LINItemClass.ItemClassCD],3) = 002 OR LEFT(LINItemClass.ItemClassCD],3) = 003 OR LEFT(LINItemClass.ItemClassCD],3) = 006, 'Class A',
LEFT(LINItemClass.ItemClassCD],3) = 007, 'Class B',
LEFT(LINItemClass.ItemClassCD],3) = 005 OR LEFT(LINItemClass.ItemClassCD],3) = 013, 'Class C',
LEFT(LINItemClass.ItemClassCD],3) = 004 OR LEFT(LINItemClass.ItemClassCD],3) = 008, 'Class D',
LEFT(LINItemClass.ItemClassCD],3) = 012, 'Class E',
LEFT(LINItemClass.ItemClassCD],3) = 010, 'Other')

The code does pass Validation, the Class column just doesn’t show even though there are at least three pages of mixed classes. I also thought about using CStr, but in this context I’m not sure of that will work.

Hi ​@wmatthews1877 ,
Try with below modified formula:
Ensured all string comparisons are with quoted values ('001' instead of 001)

=SWITCH(
    ISNULL(NINItemClass.ItemClassCD], '') = '', '',
    LEFT( INItemClass.ItemClassCD],3) IN ('001','002','003','006'), 'Class A',
    LEFT( INItemClass.ItemClassCD],3) = '007', 'Class B',
    LEFT(ÂINItemClass.ItemClassCD],3) IN ('005','013'), 'Class C',
    LEFT(/INItemClass.ItemClassCD],3) IN ('004','008'), 'Class D',
    LEFT(rINItemClass.ItemClassCD],3) = '012', 'Class E',
    LEFT(    TRUE, 'Other'
)


Acumatica didn’t like the IN clause:

 


I went and changed the formula to:

=SWITCH(LEFT([INItemClass.ItemClassCD],3) = '001' OR LEFT([INItemClass.ItemClassCD],3) = '002' OR LEFT([INItemClass.ItemClassCD],3) = '003' OR LEFT([INItemClass.ItemClassCD],3) = '006', 'Class A') as a starter, and it worked perfectly. Thank you for bringing up the fact that the numbers have to be in quotes. The DAC says they are int but I should have thought it through since there are hyphens along with the numbers which essentially changes it to a character format.
 


Reply