1

I have created a Marketing Cloud page with a form, which is supposed to be filled out by users with appropriate permissions.

What API call should I use to enable such a function on the website that checks if a specific user has appropriate permissions to fill out the form?

1 Answer 1

1

You can retrieve this information by using the SOAP API on the AccountUser object.

Here is an example call to retrieve data from the AccountUser object. This will find users with a specific email address and display the selected fields (Email, Roles and IsAPIUser in this instance).

  <script runat="server">
    Platform.Load("Core", "1.1.1");
  try {
        /* Begin Retrieve Request */
    var email = "[email protected]";
    var rr = Platform.Function.CreateObject("RetrieveRequest");
    Platform.Function.SetObjectProperty(rr, "ObjectType", "AccountUser");
    Platform.Function.AddObjectArrayItem(rr, "Properties", "Email");
    Platform.Function.AddObjectArrayItem(rr, "Properties", "Roles");
    Platform.Function.AddObjectArrayItem(rr, "Properties", "IsAPIUser");
        /* Filter Response */
    var sfp = Platform.Function.CreateObject("SimpleFilterPart");
    Platform.Function.SetObjectProperty(sfp, "Property", "Email");
    Platform.Function.SetObjectProperty(sfp, "SimpleOperator", "equals");
    Platform.Function.AddObjectArrayItem(sfp, "Value", email);
    Platform.Function.SetObjectProperty(rr, "Filter", sfp);
        /* Invoke Retrieve */
    var rows = Platform.Function.InvokeRetrieve(rr, results);
    Write(Stringify(rows));
    } catch(e) {
      Write(Stringify(e));
    }
</script>
4
  • Thank you Jason! I'm not proficient at SOAP API, do you maybe have any example what the script could look like? Commented May 21, 2019 at 7:47
  • I've updated my answer to include an example. Please mark this as answered if this is helpful. Commented May 21, 2019 at 14:01
  • Thank you! I will add this script to the automation studio - and how should I connect it with specific Cloud Page, which is supposed to verify the users and allow them to fill out the form if they have right permissions? Commented May 21, 2019 at 14:21
  • So what you would do is include this script within your cloud page and then parse the response from the API call (the "rows" variable in this example) to get information about a users roles (it's a nested object within "rows"). Once you retrieve that, you can set a flag for a variable "required_role_for_form" to true and then prevent the user from moving onto the next page/submitting the form if they have a specific role or not. Commented May 21, 2019 at 14:27

You must log in to answer this question.

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