Skip to main content
February 6, 2023
Question

Null check for Ids in a process

  • February 6, 2023
  • 2 replies
  • 0 views

I have a condition where i wanted to do null check if either of the IDs are null it shoudn't write to database. I am using this code in task output.

remove(
  wherecontains(
    or(a!isNullOrEmpty(pv!primaryId)),
    a!isNullOrEmpty(pv!selected)
  
  rule!NV_constructCDT(
    formId: pv!form.FormId,
    primaryId: pv!primaryId,
    secIds: pv!selected,
    
  ),
  
))

Do you have any ideas to optimize this implementation? Thank you

    2 replies

    mikes0011
    Brainy
    February 7, 2023

    Your expression rule can simply check for a blank rule input value on either of the IDs in question and return an empty set ({}) as appropriate.  There should be no need to bring the "remove()" function into this.

    abhayd3663
    February 7, 2023

    reject(fn!isnull, pv!primaryId) will remove nulls from an array -> pv!primaryId and return the resulting array.