Boomi

Formatting Date in Boomi

FORMATTING DATE FROM YYYY-MM-DD TO YYYYMMDD IN BOOMI.

In this blog, we will see how to format date from YYYY-MM-DD to YYYYMMDD in Boomi.

In this Use Case,

  • We will pass a sample xml document through message shape which contains date in YYYY-MM-DD format.
  • We will use map shape for custom scripting to convert the date from YYYY-MM-DD format to YYYYMMDD.

Let us begin with the steps.

Step 1: Log on to Boomi platform (https://platform.boomi.com/) with required credentials i.e Email Address and Password.

IMG_256

Step 2: Once logged into Boomi platform, we will be able to view Home page.

IMG_256

Step 3: Now, click on Services followed by Integration. We will see the Build page. Click on New.

IMG_256

IMG_256

Step 4: Once, clicked on New, we will be able to see three fields i.e., Type, Component Name and Folder.

IMG_256

  • Select Type as process as we are building a process. Component Name and Folder can be given based on your choice (i.e., which name to be given and where do we want to create the process). Click on create.

Step 5: We see that the process gets created with a start shape which is configured with AS2 Shared Server by default.

IMG_256

Step 6: Select the start shape and choose No Data. Click ok.

IMG_256

Step 7: Search for Message shape in search pallet. Drag and drop the shape onto process canvas and place it after start shape.

Screenshot (5)

Step 8: Click on configure and pass the sample xml code through message shape and click ok. Create an xml file with code below and save it.

<?xml version=”1.0″ encoding=”UTF-8″?>

<class>

<Val>

<age>21</age>

<Name>A</Name>

<Date>2020-01-01</Date>

</Val>

</class>

Screenshot (33)

Step 9: Search for Map shape in search pallet. Drag and drop the shape onto process canvas and place it after Message shape. Click on the plus button.

Screenshot (34)

Step 10: Click on the choose button on the left side I.e., on the map source.

Screenshot (35)

Step 11: Select XML from the drop down and click on the “Create new profile”.

Screenshot (36)

Step 12: Click on “Import a Profile”

Screenshot (37)

Step 13: Click on choose a file and browse for the xml file we created and click next. Click on finish.

Screenshot (38)

Screenshot (39)

Step 14:  Click on save and close.

Screenshot (40)

Step 15: Follow the same process for right side I.e., Map Destination.

Screenshot (41)

Step 16: Now, map the age and name fields as follow and click on the “+” in the Functions tab to add a new function.

Screenshot (42)

Step 17: To add custom script, we need to select the “User defined” from drop down and click on “Create new function”.

Screenshot (43)

Step 18: Give the input as “Input” and output as “Output” as below and click on “+”.

Screenshot (44)

Step 19: Select “Custom scripting” from drop down and select “Scripting” and click ok.

Screenshot (45)

Step 20: Select JavaScript from dropdown and add Input and output. Add the below script and click ok.

d = Input.toString();

regEx = new RegExp(‘-‘, “g”);

Output = d.replace(regEx,””);

  • In the first line, we will convert Input to string using “toString()” and store in a variable “d”
  • In the next two lines, we will replace “-” with “” using “replace()”.

Screenshot (46)

Step 21: Map the input and output as below and click on “Save and close”.

Screenshot (47)

Step 22: Provide one to one mapping as follows and click on “Save and close”.

Screenshot (53)

Step 23: Search for Stop shape in search pallet. Drag and drop the Stop shape onto process canvas and place it after Map shape.

Screenshot (48)

Step 24: Now Test the process by selecting the atom. Click on “Run Test”.

Screenshot (48)

Screenshot (50)

Step 25: Click on the stop shape and click on “Shape source data” and view the document.

Screenshot (51)

Step 26: We see that the date had formatted to YYYYMMDD format.

Screenshot (52)

Author

TGH Software Solutions Pvt. Ltd.

Leave a comment

Your email address will not be published. Required fields are marked *