Infor Process Designer - JSON the Sequel


I showed you how to use the JSON Parser to parse your JSON data, but there is another way you can accomplish this using JavaScript in the Assign node.


Use the File Access to load the JSON file into memory and then an Assign - JavaScript Expression - to cycle through to retrieve your input values (which could then be written out to an export variable within the same function).

x=FileAccess5480_outputData.split("\n")
for (i=0;i
{
j=JSON.parse(x[i])
emp=j.Employee
dept=j.Department
outputData+=emp+”,”+dept+”\n”
}

We know that Infor’s JSON file doesn't always include the data elements when that value doesn’t exist, so you could build an edit for the fields that might be missing;    

dept=j.Department ;if (dept===undefined) dept=””


Not just answers, providing solutions

Infor Process Designer - Don't fear JSON

A JSON file is similar to XML, but with more of a flattened design, not requiring as many tags to present the same data.


The JSON Parser node in IPA is designed to extract each line of data and create/assign the values to variables.

In the same way a MsgBuilder creates the variable on the fly, the JSON Parser will create variables.

First you have to specify where the line of data is stored - if you're loading from a Data Iterator (looping through multiple lines) or if you have File Access (with just one line of data) or if your line of data is assigned to a variable.


Next, from a copy of the file saved to your local computer, you have to load that file into IPA by clicking the Sample Document button.


Then, you will click the Set Variable button to launch the JSON Text Composition builder.


Lastly, assign variable names to the data elements you wish to retrieve from your JSON data. Since the JSON Parser creates the variables as needed, you don't have to define them on the Start node ahead of time (but you can if you want to).

The JSON Parser only reads the first line of your JSON sample file. Some systems don't create tags for data elements missing on a record therefore you may not see all of the data that may exist within the file. 

Infor's Replication Set process is like this; in order to preserve a smaller file size, it will skip the tags if there is no data to present. [This is why some developers define their variables on the Start node - so they are available throughout the flow]

One solution is to make sure that the first record of your sample file contains all of the data elements you wish to capture.

If your JSON file/data changes (new data elements), you will need to reload the sample file into the JSON Parser and click the Set Variable button again, in order to assure the parser is refreshed.

Not just answers, providing solutions

Infor Process Designer - Another look at your XML

Before I got comfortable with the XML node I was shown another way to build out my XML data. This is also useful if you don't have access to the schema file.

You can use the MsgBuilder node to build a perfectly acceptable XML tagged structure.


Not just answers, providing solutions

Infor Process Designer - My Crazy XML Part 2

We previously discussed parsing with the XML node, this time we will discuss building an XML.

Set the XML node Action to Build XML Object and reference the Schema URL (or file path to the schema file).



Click the Build button and then assign the variables to the data elements. Variables in the XML node are wrapped in { } brackets.


Use the Ctrl + Spacebar shortcut to pull up a listing of your available variables.

If you are adding multiple data elements (lines of data) to your XML, you will have to loop and add each one separately and more than likely reference a line number.

You can build different sections of your XML data in separate sections of your IPA flow and combine them together in the final XML node  you build. For example, the loop above was named journalEntryBatchLines and then referenced in the final XML as shown below.



Not just answers, providing solutions

Southwest User Group Mega Meeting


If you're attending the Southwest User Group Mega Meeting in April, look for me as I present Integrating with ION on Tuesday morning @ 10:00 am.



Infor Process Designer - My Crazy XML (Part 1)


There are two functions you can perform with the XML node; you can parse an XML variable or you can build one. An XML document has a particular layout, with tags to identify the elements and values of the data you're passing back and forth.

IPA flows are actually saved in the XML format.

In order to read the XML file (loaded into your IPA flow as a variable), you have to first parse it.

Set your XML node Action to Parse XML String and enter the variable name that hosts your XML.

If the XML value is loaded into your flow as part of a Service trigger, the variable will be _inputData

The next step will be to identify the Schema of your XML - this can be either a web URL or a file on the server.

A schema file identifies the tag names and element types (string, number, etc.) of your data and is required for the XML node to know how to parse the data. There are different tools and websites available to build the schema from your XML file if you don't already have one available.

After passing the XML data through the XML node, you still have to retrieve the values the node has parsed out for you. You will do this with an Assign node.

Warning - don't freak out with what you're about to see!


Basically, the data from the XML has an address that you need to reference. Your XML data can contain both header and detail sections and may have multiple lines of data that you reference like an array.

The first part of the 'address' is the XML_output - what comes out of your XML node - and the remaining part are the tag names of each of the data elements that contain your actual data. If you look at your source data, you will see the same tag names and it won't be hard to match up the data you need to retrieve with the address you will need to reference to retrieve that data.

If your data contains multiple detail lines, you may loop through that section and include array references [0] [1] [2] for the different lines of data (which all have the same element name).

It may take a bit of patience the first time you go through this, but once you figure it out, it's not that complicated.

In part 2 we'll discuss how to build an XML.

Not just answers, providing solutions


Infor Process Designer - Another way to look at Files


In Landmark, click Start - Data - pfi - Business Classes and then select PfiFileStorage

You will actually see a listing of the files you've written to, or FTP'd to, the Landmark server. You can view the files and copy and paste the contents to your notes application. It is another way to 'look at your files.'

Not just answers, providing solutions

Infor Process Designer - What the FTP

We've covered the File Access, reading and writing to files on the Landmark server, but what do you do when the file is on another server? You can transfer a file from or to another server using the FTP node.


First set the source and destination file path and name (you can use a variable) and select whether the source file is on a remote server or the local server. If it is on a remote server, click the Is source remote? checkbox.

For remote servers you will also have to select the Configuration which contains the connection information (IP address, User, Password & Protocol).

The non-remote server side of the transfer only needs the file path and name. You can actually initiate a file transfer between two remote servers, one to the other. In that case, both sides of the transfer would be flagged as remote and both would require the Configuration to be selected.

Like with other configurations, you can only set one FTP connection so if you have more than one FTP site you need to connect to, you will need to create multiple configurations.


Give your configuration a meaningful name and set the Host. If you are connecting to an Infor server, the IP address will be configured behind the scenes and you can just reference the address. Otherwise, you will enter an IP address for the Host.

Set the Protocol - either FTP or SFTP. 

Multi-tenant Landmark environments only allow connections to SFTP sites.

Enter the User and Password for the site you're connecting to. Some remote servers have already assigned your user with a default directory so you may only need to enter the file name, and not the full path as well.

If you're transferring to/from the local Landmark server you don't need to configure the server, you will just not check the Is Remote checkbox on the IPA node.

Not just answers, providing solutions