image

a!documentImage(
document: if(isnull(fv!item.imageId),
cons!NOIMAGE,
fv!item.imageId
)

is it possible to use fv!item with the isnull funcion? i am trying to place a image (cons!NOIMAGE) if theres no image in the database for that specific object but i get an error saying that document cant be null so I supose its returning a True boolean in the if statement 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    in reply to pedrob0002

    isnull wil typically not catch all variations of "there is no value". My approach, matured over many years, is this:

    ri!value is of type "any"

    if(
      isnull(ri!value),
      true,
      a!localVariables(
        local!typeNum: a!refreshVariable(
          value: runtimetypeof(ri!value),
          refreshAlways: true
        ),
        
        /* Strings */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Text',
          /* Ignore white space */
          len(trim(ri!value)) = 0,
          
        /* List of Variant */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Variant?list',
          all(fn!isnull, a!flatten(ri!value)),
          
        /* Lists */
        if(
          /* Try to take first item in list and cast it to a list of itself */
          /* then compare its datatype to the incoming data type */
          local!typeNum = runtimetypeof(cast(runtimetypeof({index(ri!value, 1, null)}), ri!value)),
          
          /* Flatten takes care of lists in lists in lists in ... */
          /* List has zero non-null items, length() already ignores null values*/
          length(a!flatten(ri!value)) = 0,
    
        /* DataSubsets */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}DataSubset',
          if(
            ri!value.totalCount < 0, /* This is necessary in case fetchTotalCount=false */
            if(
              isnull(ri!value.data),
              true,
              length(ri!value.data) = 0
            ),
            ri!value.totalCount = 0
          ),
    
          /* No idea what this could be so it is considered to not be null */
          false
        ))))
      )
    )

Reply
  • 0
    Certified Lead Developer
    in reply to pedrob0002

    isnull wil typically not catch all variations of "there is no value". My approach, matured over many years, is this:

    ri!value is of type "any"

    if(
      isnull(ri!value),
      true,
      a!localVariables(
        local!typeNum: a!refreshVariable(
          value: runtimetypeof(ri!value),
          refreshAlways: true
        ),
        
        /* Strings */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Text',
          /* Ignore white space */
          len(trim(ri!value)) = 0,
          
        /* List of Variant */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Variant?list',
          all(fn!isnull, a!flatten(ri!value)),
          
        /* Lists */
        if(
          /* Try to take first item in list and cast it to a list of itself */
          /* then compare its datatype to the incoming data type */
          local!typeNum = runtimetypeof(cast(runtimetypeof({index(ri!value, 1, null)}), ri!value)),
          
          /* Flatten takes care of lists in lists in lists in ... */
          /* List has zero non-null items, length() already ignores null values*/
          length(a!flatten(ri!value)) = 0,
    
        /* DataSubsets */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}DataSubset',
          if(
            ri!value.totalCount < 0, /* This is necessary in case fetchTotalCount=false */
            if(
              isnull(ri!value.data),
              true,
              length(ri!value.data) = 0
            ),
            ri!value.totalCount = 0
          ),
    
          /* No idea what this could be so it is considered to not be null */
          false
        ))))
      )
    )

Children