In this article I have tried to explain how we can use Global Variable and Data Stitch Action in an Integration.
About Global Variable : You can create complex and simple type global variables that are available for usage throughout an orchestrated integration (for example, when building an expression in the Expression Builder of an assign action).
User-defined complex type variables are defined based on the WSDLs/XSDs exposed in the integration by the trigger connection and any invokes connection. These variables are then be available throughout the integration for assignment and usage.
About Data Stitch Action : You can incrementally build a message payload from one or more existing payloads with the stitch action. The stitch action provides an editor that enables you to assign values to variables. The stitch action supports both partial and full replacement of the message payload. The stitch action also supports both scalar and complex type variables.
- Advertisement -
Hands-on Practice :
Lets develop one Integration using global variables and data stitch action :
**Prerequisite : REST Trigger and FTP Server Connection. If you don't have these connection available in your OIC Instance you can follow the below links and can configure the same.
Step 2 : Search for REST Trigger connection and select the it (in my case it's 'REST_Conn') and configure it by providing basic detail along with Request and Response payload.
- Advertisement -
- Enter any meaningful name
- Enter details as shown in below image and click Next
- Enter below Request Sample JSON Payload and then click Ok.
- Enter below Response Sample JSON Payload and click Ok.
- Click done.
- Advertisement -
Step 4 : Add the FTP Connection. In my case it's "FTP_Test".
- Enter a meaningful name
- Enter operations details and then click NEXT:
- Select Operation : Read a File
- Select a Transfer Mode : Binary
- Select "Sample delimited document (e.g CSV) " option and then click Next .
- Advertisement -
- Download GV&DataStitch-EmployeeDetail.csv file and choose the same file. After selecting the file enter below details.
- Enter the Record Name : Employee (you can give any meaningful name)
- Enter the Recordset Name. : EmployeeDetail
- Select the Field Delimiter : comma(,)
- Charter Set : UTF8
- Optionally Enclosed By : "
- Terminated By : ${eol}
- Select use first Row as column header
- Click Done
- Open mapper and map the Input with FTP request
- Advertisement -
STEP 5 : Click on '(x)' icon present at right hand side and then click 'Add Variable'
- Configure below detail :
- Name : global_var_readFileResponse (you can give any meaningful name )
- Type : Select Object type
- Select "SyncReadFileResponse*" from $readFileFromDirectory as object. And then click close icon(X). It will automatically get saved.
- Advertisement -
- Give any meaningful name and then click Configure
- Search for the global variable which we have declared above (Step 5) and then select it.
- Select Operation = Assign and Value (x) = select the FTP response as shown in below image
- Close the configuration window by clicking 'X'. It will get saved automatically
- Now Open the "GetFileData" mapper and map the output with data stitch
- Advertisement -
- Click Save and Close the integration.
- Advertisement -
Testing Steps :
- Put .csv file in your FTP server directory. In my case I am putting file at "/" root directory having file name "DataStitch.EmpDetail.csv"
- Activate the integration
- Click Run button
- Enter the request JSON payload by entering your input data. Like Your .csv file name and your file directory path.
- You can see the output in response window.
- Advertisement -
Thank You ! 😊
It helped me a lot in understanding the co-relation between global variable and data stitch
ReplyDeleteThanks Deep :)
Deletenice blog.. explained very clearly.. Thank you..
ReplyDeleteThanks Karthik :)
DeleteThanks and very well explained. I tried all steps but I got output in below format can you please let me know what I missed?
ReplyDelete{
"Employee" : {
"EmployeeDetail" : [ {
"Name" : "Ramlal Shyamlal",
"Id" : "01 02"
} ]
}
}
Dear you missed FOR EACH. Check STEP- 5 (Mapping Image)
Deleteohh yeah, missed that. such a silly mistake on my end. Sorry buddy. But thanks a lot for your quick turn around. and hats off for your amazing work. Do you have more such posts on OIC hands-on learning? If yes then where can I check that?
DeleteCheck "Hands-on link " tab present at the top of this website.
Deleteor simply you can access this URL : https://www.oicbasics.com/p/hands-on-links.html
Thanks a lot.
DeleteYou Welcome
DeleteHi, i have a question, what happens if we have a parallel processing inside a for-each and assign value with stich in a global variable with this parallel processing?
ReplyDeletewill the value of global variable replace in parallel processing or for each parallel processing will have a "instance" of the global variable?
DeleteDear currently I am not sure on this.
DeleteBut I can suggest one thing - Just develop one Integration with all the actions which you need & Test it with the different use cases:) It take time but you will get your query answer.
Beautifully explained, much appreciated
ReplyDeleteThanks :)
DeleteI want to assign only single value to a global variable but I see the complete response is getting assigned, could you please advise.
ReplyDeleteHint : don't declare your global variable TYPE as 'OBJECT' ( check step 5)
DeleteNice explanation
ReplyDelete