Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Nested Object Iterations in REST (Oracle HCM) Connection User Import

ghrk
New Contributor
New Contributor

Background:

  • An user in Oracle HCM will have multiple workRelationships associated
  • One workRelationship will have multiple assignments
  • Only one assignment will be active at a time

Requirement: is to selectively pick active assignment details.

We tried the following code in the UserImportJSON

"userResponsePath":"items"

Till this it is working
"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; int workRelationshipsCount = 0; int workRelationshipsSize = responseWorkRelationshipsList.size(); Iterator iteratorWorkRelationships = responseWorkRelationshipsList.iterator(); while (iteratorWorkRelationships.hasNext()) { workRelationshipsCount++; Map workRelationshipsDataMap = iteratorWorkRelationships.next(); List responseAssignmentList = workRelationshipsDataMap.assignments; int assingmentSize = responseAssignmentList.size(); return assingmentSize; if (workRelationshipsCount == workRelationshipsSize) {return null}}}~#~char",


Not working(We need this to be working)
"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; int workRelationshipsCount = 0; int workRelationshipsSize = responseWorkRelationshipsList.size(); Iterator iteratorWorkRelationships = responseWorkRelationshipsList.iterator(); while (iteratorWorkRelationships.hasNext()) { workRelationshipsCount++; Map workRelationshipsDataMap = iteratorWorkRelationships.next(); List responseAssignmentList = workRelationshipsDataMap.assignments; int assingmentSize = responseAssignmentList.size(); Iterator iteratorAssignments = responseAssignmentList.iterator(); while (iteratorAssignments.hasNext()) { Map assignmentsDataMap = iteratorAssignments.next(); if(assignmentsDataMap.AssignmentStatusType == 'ACTIVE') return assignmentsDataMap.JobCode; } if (workRelationshipsCount == workRelationshipsSize) { return null }}}~#~char",


We tried some other variations to test which are also not working

not working
"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; int workRelationshipsCount = 0; int workRelationshipsSize = responseWorkRelationshipsList.size(); Iterator iteratorWorkRelationships = responseWorkRelationshipsList.iterator(); while (iteratorWorkRelationships.hasNext()) { workRelationshipsCount++; Map workRelationshipsDataMap = iteratorWorkRelationships.next(); List responseAssignmentList = workRelationshipsDataMap.assignments; int assingmentSize = responseAssignmentList.size(); return responseAssignmentList; if (workRelationshipsCount == workRelationshipsSize) { return null }}}~#~char",

not working
"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; int workRelationshipsCount = 0; int workRelationshipsSize = responseWorkRelationshipsList.size(); Iterator iteratorWorkRelationships = responseWorkRelationshipsList.iterator(); while (iteratorWorkRelationships.hasNext()) { workRelationshipsCount++; Map workRelationshipsDataMap = iteratorWorkRelationships.next(); List responseAssignmentList = workRelationshipsDataMap.assignments; int assingmentSize = responseAssignmentList.size(); Iterator iteratorAssignments = responseAssignmentList.iterator(); while (iteratorAssignments.hasNext()) { Map assignmentsDataMap = iteratorAssignments.next(); return 'works' } if (workRelationshipsCount == workRelationshipsSize) { return null }}}~#~char",

not working
"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; int workRelationshipsCount = 0; int workRelationshipsSize = responseWorkRelationshipsList.size(); Iterator iteratorWorkRelationships = responseWorkRelationshipsList.iterator(); while (iteratorWorkRelationships.hasNext()) { workRelationshipsCount++; Map workRelationshipsDataMap = iteratorWorkRelationships.next(); List responseAssignmentList = workRelationshipsDataMap.assignments; int assingmentSize = responseAssignmentList.size(); Iterator iteratorAssignments = responseAssignmentList.iterator(); while (iteratorAssignments.hasNext()) { Map assignmentsDataMap = iteratorAssignments.next(); return assignmentsDataMap.AssignmentStatusType; } if (workRelationshipsCount == workRelationshipsSize) { return null }}}~#~char",

 

HCM Response:

{
"items": [
{
"PersonNumber": "1006506",
"emails": [
{
"EmailAddress": "sendmail-test-discard@oracle.com",
"EmailType": "W1"
},
{
"EmailAddress": "sendmail-test-discard@oracle.com",
"EmailType": "H1"
}
],
"externalIdentifiers": [],
"names": [
{
"FirstName": "Yesvidha",
"MiddleNames": "mamabuene",
"LastName": "Pereira"
}
],
"phones": [
{
"PhoneType": "HM",
"CountryCodeNumber": "44",
"PhoneNumber": "8470071534"
}
],
"workRelationships": [
{
"WorkerType": "E",
"LegalEmployerName": "Group",
"StartDate": "2021-05-10",
"TerminationDate": null,
"assignments": [
{
"AssignmentStatusType": "ACTIVE",
"AssignmentStatusTypeCode": "ACTIVE_PROCESS",
"ActionCode": "MANAGER_CHANGE",
"AssignmentName": "Senior Proposition Regulatory Change Manager",
"AssignmentNumber": "E1006506",
"JobCode": "JOB_00968",
"UserPersonType": "Employee",
"BusinessUnitName": "Group",
"BusinessUnitId": 300000002766815,
"DepartmentId": 300000002782861,
"DepartmentName": "152410 Product Management",
"LocationCode": "STANDARD_HOUSE",
"assignmentsDFF": [
{
"company": "ABC"
}
],
"managers": [
{
"ManagerAssignmentNumber": "E1000760",
"ManagerType": "LINE_MANAGER"
}
]
},
{
"AssignmentStatusType": "INACTIVE",
"AssignmentStatusTypeCode": "INACTIVE_PROCESS",
"ActionCode": "HIRE",
"AssignmentName": "Senior Proposition Regulatory Change Manager",
"AssignmentNumber": "P1006506",
"JobCode": "JOB_00968",
"UserPersonType": "Pending Worker",
"BusinessUnitName": "Group",
"BusinessUnitId": 300000002766815,
"DepartmentId": 300000002782861,
"DepartmentName": "152410 Product Management",
"LocationCode": "LOC_STANDARD",
"assignmentsDFF": [
{
"company": null
}
],
"managers": []
}
]
},
{
"WorkerType": "P",
"LegalEmployerName": "Group",
"StartDate": "2021-04-22",
"TerminationDate": "2021-05-09",
"assignments": [
{
"AssignmentStatusType": "INACTIVE",
"AssignmentStatusTypeCode": "INACTIVE_PROCESS",
"ActionCode": "HIRE",
"AssignmentName": "Senior Proposition Regulatory Change Manager",
"AssignmentNumber": "P1006506",
"JobCode": "JOB_00968",
"UserPersonType": "Pending Worker",
"BusinessUnitName": "Group",
"BusinessUnitId": 300000002766815,
"DepartmentId": 300000002782861,
"DepartmentName": "152410 Product Management",
"LocationCode": "LOC_STANDARD",
"assignmentsDFF": [
{
"company": null
}
],
"managers": []
}
]
}
]
}
],
"count": 10,
"hasMore": true,
"limit": 10,
"offset": 0,
"links": [
{
"rel": "self",
"href": "/hcmRestApi/resources/11.13.18.05/workers",
"name": "workers",
"kind": "collection"
}
]

9 REPLIES 9

NM
Honored Contributor II
Honored Contributor II

Hi @ghrk try this

 "#CONST#${List responseList = response.workRelationships.assignments; int count = 0; int size = responseList.size(); Iterator iterator = responseList.iterator(); while (iterator.hasNext()){count++; Map dataMap = iterator.next(); if('ACTIVE'.equals(dataMap.AssignmentStatusType)){return dataMap.DepartmentName}else if(count == size){return null}}}~#~char"

 

What do you want to do with active assignment as in map it?

ghrk
New Contributor
New Contributor

There will be many workrelationships, the code response.workRelationships.assignments, will not work.

What do you want to do with active assignment as in map it? => We need to map the active assignment attribute values to Saviynt Identity attributes

NM
Honored Contributor II
Honored Contributor II

@ghrk as per the response work relationship is an array and it contains all type of work relationship.

rushikeshvartak
All-Star
All-Star

Please try below

"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; int workRelationshipsCount = 0; int workRelationshipsSize = responseWorkRelationshipsList.size(); Iterator iteratorWorkRelationships = responseWorkRelationshipsList.iterator(); while (iteratorWorkRelationships.hasNext()) { workRelationshipsCount++; Map workRelationshipsDataMap = iteratorWorkRelationships.next(); List responseAssignmentList = workRelationshipsDataMap.assignments; Iterator iteratorAssignments = responseAssignmentList.iterator(); while (iteratorAssignments.hasNext()) { Map assignmentsDataMap = iteratorAssignments.next(); if(assignmentsDataMap.AssignmentStatusType == 'ACTIVE') { return assignmentsDataMap.JobCode; } } if (workRelationshipsCount == workRelationshipsSize) { return null }}}~#~char",

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

This didn't work

"customproperty65": "#CONST#${List responseWorkRelationshipsList = response.workRelationships; for(Map workRelationshipsDataMap : responseWorkRelationshipsList) { List responseAssignmentList = workRelationshipsDataMap.assignments; for(Map assignmentsDataMap : responseAssignmentList) { if(assignmentsDataMap.AssignmentStatusType == 'ACTIVE') { return assignmentsDataMap.JobCode; } } } return null;}~#~char"

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

SS
Regular Contributor
Regular Contributor

The above code does not work. The code works when the first element of the array (workRelationships) has an assignment that has the assignments.AssignmentStatusCode = 'Active'. This code does not work when the second element of the array (workRelationships) has the value assignments.AssignmentStatusCode = 'Active'. 

Please let us know and we can provide you with the test data.

We wrote another code which again works for the first iteration but does not work with the subsequent iterations. Can you please check why does the code does not move to the second element of the array?

"#CONST#${def activeAssignmentNumbers = response.workRelationships.findAll { workRelationship -> workRelationship.assignments.any { assignment ->assignment.AssignmentStatusType == 'ACTIVE'}}.collect { workRelationship -> workRelationship.assignments.find { assignment ->assignment.AssignmentStatusType == 'ACTIVE'}?.AssignmentNumber}}~#~char"

#CONST#${def activeAssignmentNumber = null; response.workRelationships.each { workRelationship -> workRelationship.assignments.each { assignment -> if(assignment.AssignmentStatusType == 'ACTIVE') { activeAssignmentNumber = assignment.AssignmentNumber; return activeAssignmentNumber; } } }; return activeAssignmentNumber;}~#~char


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

SS
Regular Contributor
Regular Contributor

This issue is resolved. The issue was in a parameter in the URL that was limiting the number of results.