We need to update a record in Salesforce using a Script Activity within an Automation. Ideally, I would like to use the AMPscript UpdateSingleSalesforceObject()
function to achieve this as there is no equivalent function in SSJS.
I am aware that Script Activities only work with SSJS. I have tried including my AMPscript in a Content Area and getting SSJS to call it. For example:
<script runat="server">
Platform.Load("Core","1.1.1");
try {
var stream = ContentAreaByName("my content area name");
Write(TreatAsContent(stream));
} catch(e) {
Write(Stringify(e));
}
</script>
This works in an email, but does not appear to be supported in a Script Activity.
Does anyone know of a solution for this? The only solution I can think of is to create a Connected App in Sales Cloud and then use the Sales Cloud REST API to update the Salesforce record using an SSJS Post() function. I can do this, but would prefer not to, if I can avoid it.