Skip to main content
September 24, 2021
Solved

rule() should return null, however it always return with not null value

  • September 24, 2021
  • 2 replies
  • 0 views

disabled:if(isnull(local!searchDeleteUserRole),true(),if(isnull(trim(rule!KONE_Development_userrolebackupexist_Rule(local!searchDeleteUserRole))),false(),true())),

my rule is:

 a!queryEntity(
   entity: cons!KONE_Development_userrolebackup_Constant,
   query: a!query(
     pagingInfo: a!pagingInfo(
       startIndex: 1,
       batchSize: 5000
     ),         
     selection: a!querySelection(
       columns: {
         a!queryColumn(
           field: "name"
         )
       }
     ),
     filter:a!queryFilter(
       field:"name",
       operator:"=",
       value:ri!name,
     )
   ),
 ).data

What I test from rule is always return empty, which I doubt is null value, however, if(isnull(rule!(local!value)),true(),false()), it should return true() since no value respond in the rule, but seems it always return false, so i doubt the rule always return with some not null value though it is empty. Which way I can make the empty value transfer to be null? Thanks

    Best answer by peter.lewis

    You are correct that null and empty are not the same value in Appian. In general the best way to approach this to both check if the value is null AND check how many items are in a list. The easiest way to check if there is an empty list is to use the length function.

    Personally one of the first rules I always create or import is a rule to test the behavior of "isNullOrEmpty". Something like this should work:

    or(
      isnull(ri!value),
      length(ri!value)=0
    )

    2 replies

    peter.lewis
    Employee
    September 24, 2021

    You are correct that null and empty are not the same value in Appian. In general the best way to approach this to both check if the value is null AND check how many items are in a list. The easiest way to check if there is an empty list is to use the length function.

    Personally one of the first rules I always create or import is a rule to test the behavior of "isNullOrEmpty". Something like this should work:

    or(
      isnull(ri!value),
      length(ri!value)=0
    )

    September 26, 2021

    works!