Salesforce: Don't update Record on Upsert

Five Stars

Salesforce: Don't update Record on Upsert

Hello Community 
We have several salesforce upserts and the Problem that every Upsert will change the Modified Date, even when the Record is not Changed.
I think this is the standard behaviour. 
Is it possible to leave the whole Upsert process untouched or at least the Modify Date Field from Salesforce ?
I think about, if these topic solves the Problem but I'm not sure ..sorry for my limited knowledge :  tMap - update only if value is non-Null?
best regards john 
One Star

Re: Salesforce: Don't update Record on Upsert

Hi,
This is the standard behaviour.
However, if you want to push only new or changed records to Salesforce, you need to determine by yourself the subset (select and compare records before to upsert). I suggest you to compute a before and after image using a MD5 string based on all fields of the Talend schema.
Regards,
TRF
Five Stars

Re: Salesforce: Don't update Record on Upsert

Hello TRF 
I never heard about an MD5 Based  generated Field in Talend. 
But I'm not so confident with special stuff.
Another idea, could i make an inquiry for Fields on the output Salesforce Table to check if Field is not changed ? 
Or is this more complex as the other one.
best regards john 
One Star

Re: Salesforce: Don't update Record on Upsert

Hi,
If you want to compute a MD5 "image" or signature of records, you need to do it by yourself using a tJavaXxxx component.
With tSalesforceOutput components, you can only ignore NULL values, no way to detect changed only records.
Here a little more details for my suggestion:
- select desired records from Salesforce
- compute before image (MD5 or other)
- store result + key (external key, not id) giving olgImg (tHashOutput for example)
- read records from source (CSV file, database or other) giving newRecords (tHashOutput for example)
- compute after image (MD5 or other) based on same field (be carefull to have the format for dates and decimal values) giving newImg
- inner join newImg and oldImg using tMap with both result and key (main newImg and lookup oldImg) and catch rejected records
- rejected records are those which are changed or new
  - retrieve them (using key) from newRecords
  - push them into Salesforce using Upsert operation
Hope this helps,
TRF
Five Stars

Re: Salesforce: Don't update Record on Upsert

Hello TRF
Yes,  i think  this approach helps a lot and 
idea to solve this with md5 i think is quite good ..thanks 
So..  I've seen some components in the exchange. 
May some of them could fit for us.
But honestly  i have to admit ....  I had to  rethink about the whole Topic and there some Drawbacks which  are coming in my mind.
Even when i change only modified Records, i cannot see the last "non automatic changes". 
I think this doesn't work easily. 
Neverthless thanks for your thoughts about MD 5 it helps us for other projects too..
best regards john 
One Star

Re: Salesforce: Don't update Record on Upsert

Well, if necessary I can help you to implemente the solution.
For now, 
1- define a routine (here called "GetHashCode") with a method (here getHashCode) to compute MD5 signature:
package routines;
import java.security.*;
public class getHashCode {
public static String getMD5(String strCode) {
java.security.MessageDigest msg;
String digest1 = "";
try {
msg = java.security.MessageDigest.getInstance("MD5");
msg.update(strCode.getBytes(), 0, strCode.length());
digest1 = new java.math.BigInteger(1, msg.digest()).toString(32);
}
catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return digest1.toUpperCase();
}
}

2- in tMap, call the "getMD5" method with all input fields concatened to produce the desired output:

Let me know if you need more help.
Regards,
TRF