0
votes

I got a scenario like below.

I make a call to a logic app with this example json. The projectDate object is optional. Sometimes its filled and when its not it is a null.

    {
  "data": {
    "object": {
      "ProjectId": "a7ba682e445494341e90636afc34e260",
      "ProjectDate": null
    }
  }
}

Now i have a compose action in which I compose a new dataset.

Compose

{
"ProjectDate": "",
"ProjectId": "a7ba682e445494341e90636afc34e260"

}

So it makes an empty string instead of the null value. How can i get this null value mapped?

1

1 Answers

0
votes

You can use if expression in the Compose action to judge whether the ProjectDate is null.

For example:

enter image description here

enter image description here

Expression:

if(equals(variables('ProjectDate'), ''),null,variables('ProjectDate'))

If the passed in ProjectDate is null, you should use this expression:

if(equals(variables('ProjectDate'), null),null,variables('ProjectDate'))

I did some tests and there seems to be no problem:

enter image description here

Note that you need to use body('parse')?['data']?['object']?['ProjectDate'] instead of variables('ProjectDate').