Solved

Check for data types

  • 1 July 2021
  • 6 replies
  • 475 views

Userlevel 5
Badge

How do I check for a data type in the generic inquiry screen? 

Like iif( ISNUMBER([FIELD]), True Path, False Path)

I have an Inventory Item Attribute that USUALLY holds an integer value. I wish to do math on this value when it is an integer, but when it is a text string it crashes the report. If I could do some kind of error checking like in Excel, I can force this to work by using IIF to ignore non-integer values.

icon

Best answer by ChandraM 1 July 2021, 22:09

View original

6 replies

Userlevel 7
Badge +9

Hi @Michael Hansen , Please try using IIF(CSANSWERS.Value>0 and CSANSWERS.Value <10000, true path , falsse path). ** In this case use the expected range of integer values.

 

Thanks 

Userlevel 5
Badge

Unfortunately I still get the error on exporting.

Error:

 

Time 00:05; Conversion failed when converting the nvarchar value 'HG-6/TJX-4' to data type int.

 

My Code is (there’s more surrounding it, but it seemed obfuscating to the topic):

=iif([InventoryItem.EAPACK_Attributes]>0 AND [InventoryItem.EAPACK_Attributes]<1000,

[InventoryItem.EAPACK_Attributes],1)

My Values are pack sizes for goods, so 48 is pretty much my top end integer value.

Userlevel 7
Badge +9

Hi @Michael Hansen  The other logic you can try is to check the first character in the string as shown below.

iif(

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’0’

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’1’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’2’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’3’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’4’,[InventoryItem.EAPACK_Attributes],1) 

** as the Max value is 48, I just added the range till ’4’.Extend it till 9 if required.

Thanks

Userlevel 7
Badge +9

Hi @Michael Hansen  The other logic you can try is to check the first character in the string as shown below.

iif(

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’0’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’1’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’2’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’3’ or

Left(LTrim([InventoryItem.EAPACK_Attributes]),1) =’4’,[InventoryItem.EAPACK_Attributes],1) 

** as the Max value is 48, I just added the range till ’4’.Extend it till 9 if required.

Thanks

Userlevel 5
Badge

That is cheating! I love it. Sure it’s a bit unwieldy, but until we get formal type checking, this is awesome-sauce. Thank you so much!

Userlevel 7
Badge +9

Hi @Michael Hansen Good to know that the solution worked.

Thanks

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved