Skip to main content
krishnav9816
July 23, 2022
Question

What is a null CDT ?How do I check whether the CDT is null ?

  • July 23, 2022
  • 11 replies
  • 0 views

I am new to this concepts, please explain?

    11 replies

    fredaf0001
    July 23, 2022

    A null CDT would be a data structure that does not have any values stored in it for your specific instance. So for example you have a cdt of type employee, and it looked like this - 

    CDT  - Employee
    Fields - empID, firstName, lastName

    A populated CDT would look like - 
    type!{namespace}Employee(empID: 1, firstName :"ABC", lastName:"XYZ" )

    And a null CDT would be one without any values with just an empty structure - where the value would show as 'null'.
    Another level to look at it is where the CDT exists but having empty fields - 'type!{namespace}Employee(), this creates a CDT with fields that have empty values - type!{namespace}Employee(empID: null, firstName :"", lastName:"" )

    You will notice this when you have an ri of a CDT on an interface where the CDT has not been populated with values yet. Once it gets populated the ri can be split to see the values for each field.

    July 25, 2022

    CDT is a datastructure where you can store your values as a defined manner. To check whether the CDT is null/empty or not, function is available called isNotNullorEmpty. in this function, you can put your local variable in which your are defining your cdt and this function return true/False. 

    krishnav9816
    July 25, 2022

    if I get true then what is solution?

    harshitb6843
    July 25, 2022

    A CDT is like a class. It gives structure to a raw data. 
    To check if it is null, you can simply pass the CDT type variable in a!keys() function and it will give you all the fields. Now you can run a loop on those values and use the property() function in the expression of that loop along with a!isNullOrEmpty()

    If all the values are null, then the CDT was null. Else it wasn't null. 

    krishnav9816
    July 25, 2022

    show me one example please i will do till a!keys() and perfectly gets after trying not get any values please show me one example

    harshitb6843
    July 25, 2022

    a!localVariables(
      local!keys: a!keys(ri!cdt),
      and(
        a!forEach(
          items: local!keys,
          expression: a!isNullOrEmpty(property(ri!cdt, fv!item, {}))
        )
      )
    )