Click HERE to see how Saviynt Intelligence is transforming the industry. |
09/04/2024 02:29 AM
Background:
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"
}
]
}
09/04/2024 02:57 AM
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?
09/04/2024 05:58 AM
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
09/04/2024 06:06 AM
@ghrk as per the response work relationship is an array and it contains all type of work relationship.
09/04/2024 06:35 AM
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",
09/04/2024 06:49 AM
This didn't work
09/04/2024 06:51 AM
"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"
09/06/2024 02:29 AM - edited 09/06/2024 09:16 AM
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"
09/06/2024 06:16 AM
#CONST#${def activeAssignmentNumber = null; response.workRelationships.each { workRelationship -> workRelationship.assignments.each { assignment -> if(assignment.AssignmentStatusType == 'ACTIVE') { activeAssignmentNumber = assignment.AssignmentNumber; return activeAssignmentNumber; } } }; return activeAssignmentNumber;}~#~char
09/19/2024 09:23 AM
This issue is resolved. The issue was in a parameter in the URL that was limiting the number of results.