Expression rule to compare two values

I want to write an expression rule to compare two values: 

first value is from rule input and second value from a db table field.If the values are same ,then another field(column) of my db table must be set to inactive or 0.

  Discussion posts and replies are publicly visible

Parents
  • load(
    local!dbdata:{
    {id:1,isactive:1,fieldId:1,formId:2},
    {id:1,isactive:1,fieldId:1,formId:3},
    },

    a!forEach(
    items: local!dbdata,
    expression: if(
    and(
    tointeger(fv!item.fieldId) = ri!fieldId,
    tointeger(fv!item.formId) = ri!formId
    ),
    {id:fv!item.id,isactive:0,fieldId:fv!item.fieldId,formId:fv!item.formId},
    fv!item
    )
    )
    )

    I specified dbdata as dictionary in above code. cast it to CDT using type! and write the output to database entity.

Reply
  • load(
    local!dbdata:{
    {id:1,isactive:1,fieldId:1,formId:2},
    {id:1,isactive:1,fieldId:1,formId:3},
    },

    a!forEach(
    items: local!dbdata,
    expression: if(
    and(
    tointeger(fv!item.fieldId) = ri!fieldId,
    tointeger(fv!item.formId) = ri!formId
    ),
    {id:fv!item.id,isactive:0,fieldId:fv!item.fieldId,formId:fv!item.formId},
    fv!item
    )
    )
    )

    I specified dbdata as dictionary in above code. cast it to CDT using type! and write the output to database entity.

Children
No Data