Computing not null values in a CDT

Hi,

I have a CDT which has around 50 attributes, I am required to find the count of not null attributes in my CDT. Is there a way I can do this by not creating a counter which would get updated after 70 if-else checks?

For Example:

Employee_cdt{fName:"Abc",lName:"Def",mName:"",empId:1234,empDept:""...}

A rule to return the not null attributes for Employee_cdt.

 

Thanks,

Arjun

  Discussion posts and replies are publicly visible

Top Replies

Parents
  • Is below your requirement?

    Input: Employee_cdt { fName:"Abc",lName:"Def",mName:"",empId:1234,empDept:""}
    Output: 3 or {"fName","lName" , "empId"}

    Please check the below code:

    with(
    local!empCDT: {
    name: "Ravi",
    email: "rr@gmail.com",
    phone: 123456,
    age:"",
    gender: "M",
    },
    local!cdtAttributes: {"name", "email","phone","age","gender"},
    local!notNullAttributes: apply(
    rule!test_checkAttriuteValue(
    cdt: local!empCDT,
    attribute: _
    ),
    local!cdtAttributes
    ),
    local!notNullAttributes
    )

    /* Definition of rule!test_checkAttriuteValue */

    /* This rule have 2 parameters, cdt and attribute*/

    with(
    local!attributeValue: index(
    ri!cdt,
    ri!attribute,
    null
    ),
    if(
    isnull(local!attributeValue),
    ri!attribute,
    null
    )
    )
Reply
  • Is below your requirement?

    Input: Employee_cdt { fName:"Abc",lName:"Def",mName:"",empId:1234,empDept:""}
    Output: 3 or {"fName","lName" , "empId"}

    Please check the below code:

    with(
    local!empCDT: {
    name: "Ravi",
    email: "rr@gmail.com",
    phone: 123456,
    age:"",
    gender: "M",
    },
    local!cdtAttributes: {"name", "email","phone","age","gender"},
    local!notNullAttributes: apply(
    rule!test_checkAttriuteValue(
    cdt: local!empCDT,
    attribute: _
    ),
    local!cdtAttributes
    ),
    local!notNullAttributes
    )

    /* Definition of rule!test_checkAttriuteValue */

    /* This rule have 2 parameters, cdt and attribute*/

    with(
    local!attributeValue: index(
    ri!cdt,
    ri!attribute,
    null
    ),
    if(
    isnull(local!attributeValue),
    ri!attribute,
    null
    )
    )
Children
No Data