How to create a lead of unsubscribed record (Coming from Marketing Cloud) in sales cloud?

35 Views Asked by At

Use Case - I have to fetch the unsubscribed records from All Subscribers and then all unsubscribed records will create in the lead object. (Custom way is required because if any error happens then SSJS or Ampscript can able to catch it.)

Step 1 - Fetch Unsubscribed record from All Subscriyour textbers whose status is unsubscribed.

Step 2 - Pass the Unsubscribed record into SSJS.

Step 3 - Pass SSJS Data to AMPScript.

Step 4 - Through AMPScript, Now create a record in the lead object.

`< title > Pass Data to Salesforce Lead < /title>

      <
      script runat = "server" >

      Platform.Load("core", "1.1.5");

    var fieldValue = "";

    var lookupValue = "12678654";

    var data = DataExtension.Init("TestingDataExtension").Rows.Lookup(["Email"], ["SubscriberKey"], ["lookupValue"]);

    if (data && data.length > 0) {

      fieldValue = data[0].FieldValue;

    }

    <
    /script>

    <
    h1 > Pass Data to Salesforce Lead < /h1>

      %
      % [

        var ampValue = Platform.Function.ParseString(Platform.Variable.GetValue("@fieldValue"));

        var lead = CreateSalesforceObject(

          "Lead", 4,

          "FirstName", "John",

          "LastName", "Doe",

          "Company", "ABC Company",

          "Email", ampValue

        );

      ] % %

      <
      p > Data passed to Salesforce Lead: % %= v(ampValue) = % % < /p>`
0

There are 0 best solutions below