0

We want to fetch the data from the cloud page and instead of storing that in a data extension we want to store that in salesforce but we don't want to use marketing cloud connect. Is it possible to do using Rest API and how?

closed as too broad by Lukas Lunow, Vijay Ganji, Gortonington, glls, battery.cord Sep 25 at 14:18

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Do you like to write the data from the CloudPage code to Salesforce CRM or do you like to fetch it from Salesforce CRM code from a Data Extension? – Markus Slabina Sep 24 at 6:47
  • Hi Markus, I want to write the data from the CloudPage code to Salesforce CRM – Shrijeet Khonde Sep 24 at 13:16
1

In order to interact with / write to Salesforce CRM from CloudPages without using Marketing Cloud Connect, you can access the Salesforce CRM REST-API. The easiest way to do so is by using the Marketing Cloud Language "Server-Side JavaScript", as you can make use of javascript objects to natively interact using JSON-format.

However, the default functions are limited to GET and POST calls that only let you create a record or retrieve data from it. In order to be able to update, delete, etc. you need to use Script.Util.HttpRequest and create your own requests, that suit your needs:

Approximate example code for an update:

<script runat=server>
    var req = new Script.Util.HttpRequest("https://yourInstance.salesforce.com/services/data/v20.0/sobjects/Account/yourid");
    req.setHeader("Authorization", "Bearer YOURTOKEN");
    req.setHeader("Content-Type", "application/json");
    req.method = "PATCH";
    req.postData = Stringify({
        "BillingCity" : "San Francisco"
    });

    var resp = req.send();
</script>

Related documentation:

0

You can create Schedulable apex class which runs every 1 hour(you can change interval as per your requirment). Create a Batch apex class and call from Schedulable class where it will make callout and you will get the response. Process the response you got from callout and insert the records using DML statement in batch. Keep the batch size as 100 as you know we can make only 100 callout per transaction.

Not the answer you're looking for? Browse other questions tagged or ask your own question.