Our target was to avoid retroactive changes because client wants to do mass data migration on the old records in SF’s. And as my iFlow was scheduled on delta run, so whatever the changes is happening in SF’s, the data is coming in the output file because the effective date is also getting updated while changing the old records. And it can effect the third party system because on their system the data will be updated according to the output which is coming from retroactive changes.
Solution:
I thought of using “fromDate” and “toDate” option in my Compound Employee query, where I was providing current date in fromDate and ‘9999-12-31‘ in toDate. According to the logic it should not fetch the past change record but it was fetching the past changes record also in my payload. There I came to know that fromDate and toDate logic was only to avoid the future changes record.
After that I thought filter option may help but then if I use filter then it will remove whole person tag from the payload, which I dont want.
So, I came up with solution using XSLT mapping where it will remove only the particular past changes record from the payload.
For checking the output I have created one scenario in SF’s demo system where I have done one retroactive change in the compensation information and for double checking I have done changes in compensation in future date.
This are the payload before XSLT mapping.
So to avoid the retroactive changes in the payload I have used logic in XSLT mapping that if the end date of the entity i.e., Compensation Information is less than the current date then it will remove the tag from the payload and if there is no end date or end date is greater than current date then it will pass those tag in the payload.
This is my XSLT mapping.
XSLT Mapping :
<xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”
xmlns:cpi=”http://sap.com/it/” exclude-result-prefixes=”cpi” version=”2.0″>
<xsl:output omit-xml-declaration=”yes” indent=”yes”/>
<xsl:strip-space elements=”*”/>
<xsl:template match=”node()|@*”>
<xsl:copy>
<xsl:apply-templates select=”node()|@*”/>
</xsl:copy>
</xsl:template>
<xsl:template match=”queryCompoundEmployeeResponse/CompoundEmployee/person/employment_information/compensation_information[(not(end_date >= current-date())) or end_date = ”]”/>
</xsl:stylesheet>
I wanted to check in the compensation information, so I gave the path till Compensation then under that I have applied my logic where I used current date function for checking with current date.
After applying XSLT, it is removing retroactive changes record and keeping my future change record.
So, in this way I was able to remove the retroactive changes record from the payload and only the latest changes record will pass.
I hope this blog will help you if you have the came up with the same scenarios in future. And if you have any doubt regarding this blog, feel free to question.