Skip to main content
sharmilan9331
November 18, 2024
Solved

Remove attributes with null values from a cdt

  • November 18, 2024
  • 4 replies
  • 0 views

Hi, 

I have a requirement to remove attributes with null values from a cdt, so that downstream system can consume it properly. 

Given: {a:null, b: 10, c: "", d: 20}

Expected: {b: 10, d: 20}

Please let me know if there is an easy way to do this. 

    Best answer by kumara0180

    a!fromJson(a!toJson({ a: null, b: 10, c: "", d: 20 }, true()))

    4 replies

    udhayak0001
    Inspiring
    November 18, 2024

    If you are sending this info In API ,you can use the below

    kumara0180
    November 18, 2024

    a!fromJson(a!toJson({ a: null, b: 10, c: "", d: 20 }, true()))

    gayatria0439
    November 19, 2024

    The toJson() function is used to remove null or empty values. When you set it to true, it will exclude or remove the null values from your array or data. After that, you can convert the Json data back to a standard dictionary format using the a!fromJson() function. Here am adding a snippet for your reference

    sarathkumr268295
    November 19, 2024

    Inside the integration, there will be check box called "Remove fields with null or empty values from generated JSON". This will remove the null values from the JSON. This one can be used