Question

1
Replies
50
Views
Michael Greenwood Member since 2017 8 posts
Saltech Consulting
Posted: 2 months ago
Last activity: 1 month 3 weeks ago

JSON Mapping using nested data transform for REST Connector

Problem definition

 

I am trying to use a data transform to map a request for a connect REST connector. I am using Pega 7.4.

 

I have followed the approach outlined here where it suggests using a data transform to map to JSON:

https://community.pega.com/knowledgebase/articles/data-and-integration/configuring-json-data-transform-request-data-transform-data-pages

 

My data for the request is an object that has many page and page list properties. I have created several data transforms on the relevant class(s) to map the appropriate data in the normal 're-useable' modular way. 

For example my data structure exists on a page

MyCo-Data-AppData

This has page properties of other classes e.g. MyCo-Data-AppData-Page1 MyCo-Data-AppData-Page2 etc

So the structure I need to map for example is 

TopLevelPage (MyCo-Data-AppData)

      .FirstPageProperty (MyCo-Data-AppData-Page1)

      .OptionalProperty (MyCo-Data-AppData-Page2)

 

In reality its far more nested but you get the point....

Now I create a data transform to map this "MyCo-Data-AppData.MapRequestData" 

I also create "MyCo-Data-AppData-Page1.MapPage1Data" and

"MyCo-Data-AppData-Page2.MapPage2Data"

 

I then refer to MapPage1Data and MapPage2Data in MapRequestData.

 

The issue I have is that is if the 'OptionalProperty' page does not have data then running the data transform on it creates the page property with just the pxObjClass and then empty JSON properties that I would map appear in the JSON.

The problem with this is that some of the optional properties if set then have mandatory properties within them and the json will not pass validation.

If the OptionalProperty is not present on the clipboard I want the JSON like so:

{

  "topLevelProp1" : "some data"

   "FirstPageProperty" : {

    "FirstPagePropertyA" : "some other value"

    }

}

 

However it is being created like:

{

  "topLevelProp1" : "some data"

   "FirstPageProperty" : {

            "FirstPagePropertyA" : "some other value"

    }

   "OptionalProperty" : {

             "OptionalPropertyB" : ""

   }

}

 

There doesn't appear to be a way of applying a row using a condition in the data transform to check for the page existing. 

I have experimented mixing the 'json' and 'non' json data transforms to enable conditions to be set but the structure of the jsonData isn't created as I need.

 

Question

How can I stop the json data transforms creating 'null' properties and sending them in the request? 

Pega Platform 7.4 Data Integration
Share this page LinkedIn