Skip to main content
Answer

In Generic Inquiry how do I writing an iif statement with a condition if a field is blank on a field that is a string

  • May 16, 2025
  • 2 replies
  • 121 views

Forum|alt.badge.img

I created a user defined field [Location.AttributeCHILDACCT] that is of type String ( nvarchar)

In my generic inquiry if [Location.AttributeCHILDACCT] is blank then I want it to pull in the Project Customer [PMProject.CustomerID] otherwise I want it to pull the string in [Location.AttributeCHILDACCT]

Here is my formula:

 

=iif(([Location.AttributeCHILDACCT]=' '),[PMProject.CustomerID],[Location.AttributeCHILDACCT])

 

I keep getting the error message below.  The C002452 is the [Location.AttributeCHILDACCT] field. The issue is definitely with my condition in the iif statement. Are you able to set a string to a condition of blank in a GI?  I think I just don’t have the correct syntax for the empty condition.

 

 

Best answer by lauraj46

Hi ​@eucciferri35 ,

To check for a null value, you can use the IsNull function.  It will return the first value if not null, otherwise the second value.

I think your error message is actually because of a data type conflict.

CustomerID is an integer.  Attributes are normally stored as strings.

I would suggest adding the Customer DAC to your generic inquiry and join the PMProject.CustomerID = Customer.BAccountID

Then change your formula to:

=IsNull([Location.AttributeCHILDACCT],[Customer.AcctCD])

Hope this helps!

Laura

2 replies

lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • Answer
  • May 16, 2025

Hi ​@eucciferri35 ,

To check for a null value, you can use the IsNull function.  It will return the first value if not null, otherwise the second value.

I think your error message is actually because of a data type conflict.

CustomerID is an integer.  Attributes are normally stored as strings.

I would suggest adding the Customer DAC to your generic inquiry and join the PMProject.CustomerID = Customer.BAccountID

Then change your formula to:

=IsNull([Location.AttributeCHILDACCT],[Customer.AcctCD])

Hope this helps!

Laura


Forum|alt.badge.img
  • Author
  • Varsity I
  • May 16, 2025

Thanks  ​@lauraj46   That’s helpful I will definitely try that.  I also had a feeling it wasn’t just the synax of looking for a blank field. I did notice that even though the user defined attribute is a selector field it converts the value to a string.  I had tried using a different field value that was also a string but didn’t like either so I did suspect that it didn’t like that true was an int and false was a string.