cancel
Showing results for 
Search instead for 
Did you mean: 

How to get fields of previous record into current record in SAP CI Using Groovy Or XSLT mapping

Nikhil_Gursal
Participant
0 Kudos
560

Hi Community,

I'm working on scenario - To fetch records from SuccessFactors from EmpJob entity with query parameter fromDate and toDate , so im getting all job history of employee from SF.

I need few fields of employee from its immediate previous record in mapping for validation and want to sent these previous fields along with Current record in mapping as a source.

Input payload will be having multiple record for different user with there historical job data , i want unique records with current job record along with three fields from immediate previous job for each employee.

To identify current and previous record below is the condition :

The current record - Sort record based on seqNumber and startDate in descending order (maximum seq no must be picked) which will be having latest start date (Nearest to current date)

Immediate previous record - endDate field in previous record will be day before startDate of current record.

Below are the three fields required from immediate previous record.

1.company
2.employeeClass
3.label --> whose Locale is en_US

Input payload : Below is the payload for single employee with its current and past historical data, we may receive this for multiple users along with there historical data)

<EmpJob>
	<EmpJob>
		<userId>12345</userId>
		<customString130Nav>
			<PicklistOption>
				<picklistLabels>
					<PicklistLabel>
						<label>CurrentDC_Professional - Full Time Office</label>
						<locale>en_US</locale>
					</PicklistLabel>
					<PicklistLabel>
						<label>DC_Professionnel - Temps plein</label>
						<locale>fr_FR</locale>
					</PicklistLabel>
				</picklistLabels>
			</PicklistOption>
		</customString130Nav>
		<startDate>2023-10-09T00:00:00.000</startDate>
		<endDate>2023-10-31T00:00:00.000</endDate>
		<company>Current5010</company>
		<employeeClass>64981</employeeClass>
		<employmentType>90707</employmentType>
		<seqNumber>2</seqNumber>
	</EmpJob>
	<EmpJob>
		<userId>12345</userId>
		<customString130Nav>
			<PicklistOption>
				<picklistLabels>
					<PicklistLabel>
						<label>DC_Professional - Full Time Office</label>
						<locale>en_US</locale>
					</PicklistLabel>
					<PicklistLabel>
						<label>DC_Professionnel - Temps plein</label>
						<locale>fr_FR</locale>
					</PicklistLabel>
				</picklistLabels>
			</PicklistOption>
		</customString130Nav>
		<startDate>2023-10-09T00:00:00.000</startDate>
		<endDate>2023-10-09T00:00:00.000</endDate>
		<company>CO_DC_5010</company>
		<employeeClass>64981</employeeClass>
		<employmentType>90707</employmentType>
		<seqNumber>1</seqNumber>
	</EmpJob>
	<EmpJob>
		<userId>12345</userId>
		<customString130Nav>
			<PicklistOption>
				<picklistLabels>
					<PicklistLabel>
						<label>PreDC_Professional - Full Time Office</label>
						<locale>en_US</locale>
					</PicklistLabel>
					<PicklistLabel>
						<label>DC_Professionnel - Temps plein</label>
						<locale>fr_FR</locale>
					</PicklistLabel>
				</picklistLabels>
			</PicklistOption>
		</customString130Nav>
		<startDate>2023-08-04T00:00:00.000</startDate>
		<endDate>2023-10-08T00:00:00.000</endDate>
		<company>Previous_5010</company>
		<employeeClass>Pre64981</employeeClass>
		<employmentType>90707</employmentType>
		<seqNumber>1</seqNumber>
	</EmpJob>
</EmpJob>

Output should be like below : Im just thinking if we can add these three previous record fields into current record with prefix "pre" so it can be directly usable in mapping.

<EmpJob>
	<EmpJob>
		<userId>12345</userId>
		<customString130Nav>
			<PicklistOption>
				<picklistLabels>
					<PicklistLabel>
						<label>CurrentDC_Professional - Full Time Office</label>
						<locale>en_US</locale>
					</PicklistLabel>
				</picklistLabels>
			</PicklistOption>
		</customString130Nav>
		<startDate>2023-10-09T00:00:00.000</startDate>
		<endDate>2023-10-31T00:00:00.000</endDate>
		<company>Current5010</company>
		<employeeClass>64981</employeeClass>
		<employmentType>90707</employmentType>
		<seqNumber>2</seqNumber>
		<precompany>Previous_5010</precompany>
		<prelabel>PreDC_Professional - Full Time Office</prelabel>
		<preemployeeClass>Pre64981</preemployeeClass>
	</EmpJob>
</EmpJob><br>

I tried to achieve this using slandered mapping functions but not working, any help be appreciated.

Thanks in advance,

Nikhil

Accepted Solutions (1)

Accepted Solutions (1)

Nikhil_Gursal
Participant
0 Kudos

Hi , I'm able to achieve requirement using Content Enricher by passing day before date of startDate into SF query to get record matching with endDate and merging additional fields into original payload,thanks.

Answers (0)