Search This Blog

Friday, March 3, 2017

Providing JSON From PeopleSoft Using Document Technology

It is possible to provide JSON from PeopleSoft without using JavaScript. This works with the help of Document Technology, Integration Broker and PeopleCode.

Below are the steps to provide JSON from PeopleSoft.

1. Create Document structure to match your requirement. 
In this example, I am providing Person details along with multiple address data for that person from PeopleSoft.

The document will look like this:

2. Create the REST Service and Service Operation for the Document

3. Create the data population App Package
This is the sample Application Package and which does the binding of the data to the Document. This is a pretty neat process.

In the Handler OnRequest:

/* Get the Parent Node */
&AO = &returnCom.GetPropertyByName("PersonBucket");

/* Create an instance for the parent node */
&AC = &AO.CreateItem();

/* Then get the Parent node field */
&pr = &AC.GetPropertyByName("CSEmplid");
&pr.Value = String(&SPEMPLID);

And so on to fill the parent fields.
For the child collection.

/* Get the child compound element */
&ACO = &AC.GetPropertyByName("ElementAddress");
&ACC = &ACO.CreateItem();
/* Get the child compound element field name */
&pr = &ACC.GetPropertyByName("AddressType");
&pr.Value = &eADDRESS_TYPE;

/* This piece of code takes care of concatenating multiple rows of the child entity and maintains the one to many relationship */

  &ret = &ACO.AppendItem(&ACC);

Note: The resulting web service data will be in the JSON format. However, if you want to provide the XML data using the same setup. Make the below change in the Service Operation > Message Instance.

4. Test the Web Service

Test it using Postman or your favorite application.

And that's it. You have provided JSON using Document Technology.

No comments:

Post a Comment