cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Compare two Json arrays to find the new and updated records

ankuragarawal
Not applicable

 

Hello Team,

I am new to Workato, i am trying to build a data integration to sync data from Workday to SharePoint List.

I have employee data coming from Workday, which is also stored in a SharePoint list. My requirement is to set up a daily integration that checks for new employees in Workday and adds them to the SharePoint list. Additionally, the integration should identify any changes to existing employee records and update the SharePoint list accordingly.

What is the recommended way to achieve it without using Foreach loop?

JSON1=[
{
"lastName": "Smith",
"User_Name": "jsmith1",
"Email_-_Work": "jsmith@example.com",
"Company": "TechCorp",
"Position": "Developer",
"Legal_Last_Name": "Smith",
"Employee_ID": "12345"
},
{
"lastName": "Smith",
"User_Name": "jsmith2",
"Email_-_Work": "jsmith@example.com",
"Company": "TechCorp2",
"Position": "Developer",
"Legal_Last_Name": "Smith",
"Employee_ID": "12345"
}
{
"lastName": "Smith",
"User_Name": "jsmith3",
"Email_-_Work": "jsmith@example.com",
"Company": "TechCorp",
"Position": "Developer",
"Legal_Last_Name": "Smith",
"Employee_ID": "12345"
}
]
JSON2=[
{
"lastName": "Smith",
"User_Name": "jsmith1",
"Email_-_Work": "jsmith@example.com",
"Company": "TechCorp",
"Position": "Developer",
"Legal_Last_Name": "Smith",
"Employee_ID": "12345",
"ID": "1"
},
{
"lastName": "Smith",
"User_Name": "jsmith2",
"Email_-_Work": "jsmith@example.com",
"Company": "TechCorp3",
"Position": "Developer",
"Legal_Last_Name": "Smith",
"Employee_ID": "12345",
"ID": "2"
}
]

JSON1 is my main data source which should synced with SharePoint list, once we identify the changes, we can update/create in the SharePoint list, please note that SharePoint will have the extra column called "ID" which needs to be ignored when matching as this column is needed to update in SharePoint.


Any suggestions are highly appreciated.

3 REPLIES 3

Prudvi
Deputy Chef II
Deputy Chef II

Hi Ankur,
Did you try this trigger option https://docs.workato.com/connectors/workday/new_updated_object.html.
This trigger picks each record whenever it is either created or updated.
PS: This is not a batch option.
Regards,
Prudvi

nitishjain
Not applicable

you need to use Python script to compare the records and pick unique records.

shivakumara
Executive Chef I
Executive Chef I

Hi @ankuragarawal ,
Assumptions: with the above requirements, you able to fetch the records from both Workday and Share-point application.
Problem statement: You need a help in comparing two output response of both the application (Workday and Share-point)

Solution:  Pass the both the response as input to the Python component and where create two list 
                     1. Create_list: To create new records in  Share-point
                    2. Update_list: To update the existing records in Share-point

Feel free to reach out if you need any further assistance.

Python code.PNG

Thanks and Regards,
Shivakumara A