SAP - Managing futur job_information in IDN Connector

Hello everyone :nerd_face:

Context

We recently deployed SAP SuccessFactor within our IT services and encountered a problem with the provisioning of users who had several job_information within SAP when the HR department anticipated changes to users (transfers or manager changes for example). The direct effect was that IDN carried out the changes in our user’s identity (authoritative source) as soon as these job_information were modified, without taking into account the start_date specified by the HR department, with the consequence that rights were lost/accessed.

Objectives

  • Do not process SAP data if job_information has a start_date in the future, except if all job_information are in the future (allows you to retrieve information for a user soon to join the company without waiting until D1 of his arrival).
  • Recover the last job_information with a start_date in the past.

Resources

I’ve found several resources on the forum or in the documentation, but these are not complete and do not fully meet my needs:

The latter gives examples of how to use Xpath (v2.0) to filter the results obtained by the SAP connector but which didn’t work in my environment :thinking:

Testing xPath

Testing a new Xpath via xpather.com:

New Xpath and explanation :

if (count(//employment_information/job_information[xs:date(start_date) le current-date()]) eq 0) then
(//employment_information/job_information/job_title)[last()]
else (//employment_information/job_information[xs:date(start_date) le current-date()]/job_title)[1]

If there are no job_information with a start_date in the past:

  • Retrieves the job_title of the most recent job_information in the future for upcoming arrivals.

Otherwise:

  • Retrieves the job_title of the most recent job_information with a start_date in the past.

Use Case 1: User with job_information in the past AND in the future

  • Objective: Assuming it’s 24/04/2024, IDN should retrieve the job_information with the most recent start_date in the past, where the user James BOND is titled as “Senior Spy”.

  • Test Data:

<sfobject>
	<id>007</id>
	<type>CompoundEmployee</type>
	<person>
		<personal_information>
			[*REDACTED*]
			<business_first_name>James</business_first_name>
			<business_last_name>BOND</business_last_name>
			<start_date>2023-01-01</start_date>
		</personal_information>
		<employment_information>
			[*REDACTED*]
			<start_date>2023-01-01</start_date>
			<user_id>007</user_id>
			<job_information>
				[*REDACTED*]
				<job_title>Spy Chief Officer</job_title>
				<start_date>2025-01-01</start_date>
			</job_information>
			<job_information>
				[*REDACTED*]
				<job_title>Senior Spy</job_title>
				<start_date>2024-01-01</start_date>
			</job_information>
			<job_information>
				[*REDACTED*]
				<job_title>Junior Spy</job_title>
				<start_date>2023-01-01</start_date>
			</job_information>
		</employment_information>
	</person>
</sfobject>

Use Case 2: User with job_information in the past only

  • Objective: Assuming it’s 24/04/2024, IDN should retrieve the job_information with the most recent start_date in the past, where the user James BOND is “Senior Spy”.

  • Test Data:

<sfobject>
	<id>007</id>
	<type>CompoundEmployee</type>
	<person>
		<personal_information>
			[*REDACTED*]
			<business_first_name>James</business_first_name>
			<business_last_name>BOND</business_last_name>
			<start_date>2023-01-01</start_date>
		</personal_information>
		<employment_information>
			[*REDACTED*]
			<start_date>2023-01-01</start_date>
			<user_id>007</user_id>
			<job_information>
				[*REDACTED*]
				<job_title>Senior Spy</job_title>
				<start_date>2024-01-01</start_date>
			</job_information>
			<job_information>
				[*REDACTED*]
				<job_title>Junior Spy</job_title>
				<start_date>2023-01-01</start_date>
			</job_information>
		</employment_information>
	</person>
</sfobject>

Use Case 3: User with job_information in the future only (upcoming arrival)

  • Objective: Assuming it’s 24/04/2024, IDN should retrieve the job_information with the closest start_date in the future, where the user James BOND is “Junior Spy”.

  • Test Data:

<sfobject>
	<id>007</id>
	<type>CompoundEmployee</type>
	<person>
		<personal_information>
			[*REDACTED*]
			<business_first_name>James</business_first_name>
			<business_last_name>BOND</business_last_name>
			<start_date>2023-01-01</start_date>
		</personal_information>
		<employment_information>
			[*REDACTED*]
			<start_date>2023-01-01</start_date>
			<user_id>007</user_id>
			<job_information>
				[*REDACTED*]
				<job_title>Senior Spy</job_title>
				<start_date>2026-01-01</start_date>
			</job_information>
			<job_information>
				[*REDACTED*]
				<job_title>Junior Spy</job_title>
				<start_date>2025-01-01</start_date>
			</job_information>
		</employment_information>
	</person>
</sfobject>

Modifying the SAP Connector in IDN to Address the Problem

  1. Set Up the SAP Connector:
    Navigate to Admin > Connections > Sources > SAP_SuccessFactors in IDN.

  2. Edit Configuration:
    Click on the “edit configuration” button.

  3. Access Advanced Settings:
    Go to the “Advanced Settings” tab, where you’ll find “Attribute Mapping”.

  4. Modify the XPath:
    Replace your current XPath with the following expression:

    if (count(//employment_information/job_information[xs:date(start_date) le current-date()]) eq 0) then (//employment_information/job_information/job_title)[last()] else (//employment_information/job_information[xs:date(start_date) le current-date()]/job_title)[1]
    

  1. Adjusting the “job_title” Attribute:
    You’ll need to adjust the "job_title" attribute to suit your needs. Below is an example of how the connector might look after the modification:

    Example of post-modification connector setup:
    - Connector Name: SAP_SuccessFactors
    - Attribute: job_title
    - Original XPath : /person/employment_information/job_information/job_title
    - XPath Modified: if (count(//employment_information/job_information[xs:date(start_date) le current-date()]) eq 0) then (//employment_information/job_information/job_title)[last()] else (//employment_information/job_information[xs:date(start_date) le current-date()]/job_title)[1]
    

End

I hope it will be useful to others,

If you have any questions or comments, I’d be delighted to hear from you,

Have a nice day,

Thomas

1 Like

Hi @tdelorge-mmb
Since you are adding below XPATH, The last part “/job_title)[1]” seems static, You are always choosing the second job_title. How do you know that second job_title is always the correct one ?

  • XPath Modified: if (count(//employment_information/job_information[xs:date(start_date) le current-date()]) eq 0) then (//employment_information/job_information/job_title)[last()] else (//employment_information/job_information[xs:date(start_date) le current-date()]/job_title)[1]

Hi Chhiring,

[1] is a false friend here, the list in XPath seem like to start at index 1 and not index 0 as usual programmation languages :


But this [1] it’s not mandatory in fact because IDN select himself the first item of the result list : 8 results for job_title in the past, but IDN just bring the last one in the user account (most recent, order made by SAP API)

1 Like

so are you saying SAP successfactor API order them by most recent automatically OR is there something needs to be done to order them by most recent ?

SAP API output are ordered by start_date attribute within <job_information> from newest to older

1 Like