0

I'm trying to update a custom field on the Campaign Member object through SSJS by taking it's value from a Data extension.

Here's the SSJS script:

<script runat="server">
Platform.Load("Core","1");

var debug = 1;
var records = DataExtension.Init("unsubscribesFromQuickLink");
var data = records.Rows.Retrieve({Property:"updatedFlag",SimpleOperator:"equals",Value:0});
var datalength = data.length;

for (var i = 0 ; i < data.length ; i ++) {
    var sf_fieldUpdateString = [];
    sf_fieldUpdateString.push('HasOptOutOfTalent__c');
    sf_fieldUpdateString.push(data[i].HasOptOutOfTalent__c);

    var updateSFObject = "";
    updateSFObject += "\%\%[ ";
    updateSFObject += "set @salesforceFields = UpdateSingleSalesforceObject('CampaignMember',";
    updateSFObject += "'" + data[i].CampaignMemberId + "','" + sf_fieldUpdateString.join("','") + "'";
    updateSFObject += ") ";
    updateSFObject += "output(concat(@salesforceFields)) ";
    updateSFObject += "]\%\%";


    try {

      results = Platform.Function.TreatAsContent(updateSFObject);

    } catch (e) {

      if (debug) { Write("<br>updateSF error: " + Stringify(e)); }

    }

}
</script>

Here's what my unsubscribesFromQuickLink DE contains: enter image description here

Script runs smoothly in the automation and gives no error, but no update happens on that campaign member's field.

I tried changing the Platform.Load("Core", "1.1.1") to Platform.Load("Core", "1") (I read somewhere that this could cause issue with the script) but nothing changed. unsubscribesFromQuickLink is also the DE external key, so that's not the issue.

I don't really know what to look for. What could the problem be?

1 Answer 1

0

Solved - it was a mispelling. The field HasOptOutOfTalent__c had a capital C at the end in the data extension.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .