Attribute Assistant Expression help

6170
12
09-15-2011 01:46 PM
LarryPhillips
New Contributor II
Where can I find documentation on what type of arguments work with the expression value method in the DynamicTable for the infrastructure editing toolbar's attribute assistant?

I'm having some trouble with data types among other things.  One example looks like this:

...IIF([INSTDATE]="","NONE",YEAR([INSTDATE]))...

I get an error of wrong data type while this work fine:

...", YEAR INSTALLED " & YEAR([INSTDATE])...

I used the "" because I could not figure out the syntax for ISNULL.

I get alot of syntax errors not knowing what functions/operators work with the Expression Value Method.
0 Kudos
12 Replies
MikeMillerGIS
Esri Frequent Contributor
After we translate the fields to values, we pass the expression to the MSScriptControl.ScriptControlClass object.  I think you want to us the isNull expression, so like below:

IIF(isNull([FIELD]),TrueValue,FalseValue)
0 Kudos
LarryPhillips
New Contributor II
Row Info
        Row Number 1
        TableName: SWR_Manholes
        FieldName: UNITDESC
        ValueInfo: IIF(isNull([MHDPTH]),"UNKNOWN",[MHDPTH])
        ValueMethod: EXPRESSION
        On Create: 1
        On Change: 0
        Order: 6

      Checking for Subtype Restriction
      The Field in the Field Name is not found: value(25)
                  Trying: EXPRESSION
                  replace field: MHDPTH with a value
                  replace field: MHDPTH with a value
                  ERROR: evaluating the expression for feature in SWR Manholes with OID of 24849
                         Syntax error
                  Finished: EXPRESSION



After we translate the fields to values, we pass the expression to the MSScriptControl.ScriptControlClass object.  I think you want to us the isNull expression, so like below:

IIF(isNull([FIELD]),TrueValue,FalseValue)
0 Kudos
MikeMillerGIS
Esri Frequent Contributor
Can you download the beta and try that?  I fixed a bug that might be the cause of your issue.
0 Kudos
LarryPhillips
New Contributor II
Ok, I have the Beta installed and tested.

The isNull still doesn't work, the same way it didn't work before.  If there is a value it passes a "false" if the value is <null> I get a syntax error.

IIF([INSTDATE]="","NONE",YEAR([INSTDATE]))

First run results: INSTDATE=somevalue I get the year of that value!  yeah.
First run results: INSTDATE=<null> I get "NONE"! yeah.
run results: INSTDATE=somevalue then set it to null I get a data type error. Boo!
run results: INSTDATE=<null> then set a date I get the year of that date! yeah!


One more issue, when I set a nonstring data type fields (ie; Double) ="" I get a data type error if it is null.

Here's to me wishing there was an emoticon beating it's head against the wall because thats how I feel.
0 Kudos
MikeMillerGIS
Esri Frequent Contributor
You cannot set a non string field to an empty string.  Even an empty string is a string.  If you are trying to set a value as null, I am not sure you can.  We would need to translate a value you entered as null to a true null value.  Would you want use to translate <Null> to null?
0 Kudos
SamAdam
New Contributor

Hi Michael,

I know this is an old post , but is it possible in the current version of Attribute Assistant to set string or numeric fields to Null,  if yes then how we can simply set the field to Null ?

The only reference I could find and it didn't work with me was below, I have tried VBNull and Null in the IIF below but also didn't work :

Attribute operations - Attribute Assistant | ArcGIS Solutions 

  • To set values as null, use an empty string:

    • Invalid: IIF([LOCDESC]=0, "<NULL>", [LOCDESC])
    • Valid: IIF([LOCDESC]=0, "", [LOCDESC])
0 Kudos
MikeMillerGIS
Esri Frequent Contributor

What is the log file reporting, reviewing the code <Null> should work, try without the " " around it

0 Kudos
SamAdam
New Contributor

I have found that none of the following combinations of configurations sets the field to Null:

Expression  : IIF(1 = 1 , Null, Null)  => this results in an empty string instead of Null. Log file looks fine with no errors

Log File :

                  Trying: EXPRESSION
                  Checking to verify there is a field to store the expression
Expression to be eval: iif(1 = 1,Null,Null)
                  Setting Value to:
                  Finished: EXPRESSION

-----

Expression : IIF(1 = 1 , <Null>,<Null>) => this does nothing as it is considered syntactically incorrect as per log file:

Log File :

Trying: EXPRESSION
                  Checking to verify there is a field to store the expression
Expression to be eval: iif(1 = 1,<Null>,<Null>)
                  ERROR: evaluating the expression for feature in AA_VOne with OID of 1
                         Syntax error
                  Finished: EXPRESSION

-----

Expression  : IIF(1 = 1 , "", "")  => this results in an empty string instead of Null which doesn't align with the online reference in my previous post above. Log file looks fine with no errors:

Log File :

                  Trying: EXPRESSION

                  Checking to verify there is a field to store the expression
Expression to be eval: iif(1 = 1,"","")
                  Setting Value to:
                  Finished: EXPRESSION

----

Expression  : IIF(1 = 1 , vbNull, vbNull)  => this results in the value of the vbNull which is 1 string instead of Null. Log file looks fine with no errors

Log File :

                  Trying: EXPRESSION
                  Checking to verify there is a field to store the expression
Expression to be eval: iif(1 = 1,vbNull,vbNull)
                  Setting Value to: 1
                  Finished: EXPRESSION

-----

Expression : IIF(1 = 1 , <Null>,<Null>) => this does nothing as it is considered syntactically incorrect as per log file:

Log File :

                  Checking to verify there is a field to store the expression
Expression to be eval: <Null>
                  ERROR: evaluating the expression for feature in AA_VOne with OID of 1
                         Syntax error
                  Finished: EXPRESSION

0 Kudos
SamAdam
New Contributor

After trying many combination , the correct way to set the field to null is what is mentioned in the documentation as 'Invalid' below !

You have to use (in the simplest case) Expression = "<Null>" . that will work with string or numeric field data type , and can also be used in IIF expression or any complex VBScript expression.

Empty sting as mentioned below will never set the field to Null, regardless of the data type of the field.

Attribute operations - Attribute Assistant | ArcGIS Solutions 

  • To set values as null, use an empty string:

    • Invalid: IIF([LOCDESC]=0, "<NULL>", [LOCDESC])
    • Valid: IIF([LOCDESC]=0, "", [LOCDESC])
0 Kudos