Last active
March 6, 2023 13:13
-
-
Save katydorjee/818912244f95c49c0bf52c175d00cfe8 to your computer and use it in GitHub Desktop.
Update Salesforce Object Using SSJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat="server"> | |
Platform.Load("core","1.1.1"); | |
var sfUpdateString; | |
var targetDE = DataExtension.Init('External Key').Rows.Retrieve(); | |
for (var i = 0; i < targetDE.length; i++) | |
{ | |
var Field1 = targetDE[i].Field1; | |
var Field2 = targetDE[i].Field2; | |
sfUpdateString = ''; | |
sfUpdateString = '%'+'%[SET @uso = UpdateSingleSalesforceObject("Contact","'+Field1+'"'; | |
sfUpdateString += ',"Field2","'+Field2+'")]%'+'%'; | |
Platform.Function.TreatAsContent(sfUpdateString); | |
Write(Platform.Variable.GetValue("@uso")); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am new to SFMC hence not sure whether this code will handle the bulk update. As we know in salesforce update, insert, and delete we can not use inside the for loop(as per best practice), instead we will add the first data into the list and then will update the whole list, hence want to confirm if I have 10 records then using the above code it's fine to update one by one or need to add first in the list and then update, please help me to understand as i want to use the above code in my current implementation.