4

I am working on custom activity in Journey builder where, I need to access the values of the fields from Subscriber profile attribute as inArguments. I read about data binding from here and used the below syntax to access profile attribute values:

{{Contact.Attribute.Persona.sub_id}}

But, I receive empty string in the sub_id field and I am sure there is value present for this field in Subscriber.

config.json

{
  "workflowApiVersion": "1.1",
  "metaData": {
    "icon": "img/img_1.png",
    "iconSmall": "img/img_2.png",
    "category": "message"
  },
  "type": "REST",
  "lang": {
    "en-US": {
      "name": "Test custom activity",
      "description": "Testing custom activity"
    }
  },
  "arguments": {
    "execute": {
      "inArguments": [
        {
          "sub_id": "{{Contact.Attribute.Persona.sub_id}}"
        },
        {
          "firstName": "{{Contact.Attribute.DE_NAME.FirstName}}"
        },
        {
          "lastName": "{{Contact.Attribute.DE_NAME.LastName}}"
        },
        {
          "emailAddress": "{{Contact.Default.Email}}"
        }
      ],
      "outArguments": [],
      "url": "https://xyz.ngrok.io/activities/execute",
      "verb": "POST",
      "body": "",
      "header": "",
      "format": "json",
      "useJwt": false,
      "timeout": 10000
    }
  },
  "configurationArguments": {
    "applicationExtensionKey": "test-activity-custm-wwq",
    "defaults": {
      "activity": "0"
    },
    "save": {
      "url": "https://xyz.ngrok.io/activities/save",
      "useJwt": false
    },
    "publish": {
      "url": "https://xyz.ngrok.io/activities/publish",
      "verb": "POST",
      "body": "",
      "useJwt": false
    },
    "validate": {
      "url": "https://xyz.ngrok.io/activities/validate",
      "verb": "POST",
      "body": "",
      "useJwt": false
    },
    "stop": {
      "url": "https://xyz.ngrok.io/activities/stop",
      "useJwt": false
    }
  },
  "wizardSteps": [
    {
      "label": "Select anything",
      "key": "1"
    },
    {
      "label": "Confirm Settings",
      "key": "2"
    },
    {
      "label": "Save Settings",
      "key": "3",
      "active": false
    }
  ],
  "userInterfaces": {
    "configModal": {
      "height": 250,
      "width": 600,
      "fullscreen": false
    }
  }
}

Received inArguments in Execute API :

{"inArguments"=>[{"sub_id"=>""}, {"firstName"=>"Test"}, {"lastName"=>"Name"}, {"emailAddress"=>"testemail+62@gmail.com"}]

Also, I have tried accessing the profile attribute values as below:

{{Contact.Default.sub_id}}

But, it display the below error in the Journey history status column:

Failed - ExactTarget.JourneyBuilder.Activities.RestActivity.execute: Error binding data bound member.

Is anything I am doing wrong, please help me.

Thanks.

  • Do you have a 1:1 cardinal relationship in your Contact Model (i.e. an Attribute Group in Data Designer) to your 'Persona' Data Extension? Is there always a value for sub_id for each Contact? – Eliot Harper Jul 7 '17 at 3:32
  • @EliotHarper, I am able to access the value of a field in Data Extension but, here I need to access the value of a subscriber profile attribute field and not a Data Extension field. – Gokul M Jul 7 '17 at 3:51
  • @EliotHarper, FYI: I have a population in Contact builder data designer related to a Data Extension in 1:1 relationship. – Gokul M Jul 7 '17 at 4:06
  • You can only use data binding in the Contact, Journey or Event context. You can't use data binding to reference Subscriber Profile Attributes, so this won't work. However, don't despair, there is another solution. Before I share that, can you explain what are you using that Subscriber Profile Attribute for? I assume that's needed for something in your Custom Activity, is that correct? – Eliot Harper Jul 7 '17 at 4:44
  • But, here the documentation contains syntax for accessing the profile attribute but, not working for me. I need the profile attribute value for my custom activity. So, please tell me how to access it. – Gokul M Jul 7 '17 at 5:20
5
+50

Update

It has just occurred to me that it is possible to retrieve Email Subscriber Profile Attributes using Data Binding. I don't know why this didn't occur to me earlier. Simply use the string:

{{Contact.Attribute."Email Demographics".sub_id}}

Note that this will only work for required attributes. If sub_id is nullable (that is, it does not contain a value for a Subscriber) then the Contact will fail at the Custom Activity. To overcome this, use block helpers to determine if there is a value and send a default value to the inArgument if it does not exist. For example:

{{#if Contact.Attribute."Email Demographics".sub_id}}
   {{Contact.Attribute."Email Demographics".sub_id}}
{{#else}}
   0
{{/if}}

Note that you will probably need to include this on a single line in your config.json file, I've beautified it for ease of reading. e.g. use:

{{#if Contact.Attribute."Email Demographics".sub_id}}{{Contact.Attribute."Email Demographics".sub_id}}{{#else}}0{{/if}}

Previous Answer

Including previous answer as it still may be valid for some use cases.

You will need to make a separate SOAP API request to get the Subscriber Profile Attribute to use in your Custom Activity.

For example, pass the Subscriber Key for the Contact using the data binding {{Contact.Key}} as an inArgument, then get make a separate SOAP API request from your application using the request below.

You can copy and paste this working example into Postman.

You will need to set the {{soapEndPoint}} to the appropriate SOAP Endpoint for your instance. Note that you can use the REST API to retrieve the SOAP endpoint for the instance where your application is installed on using the getEndpoints method.

POST {{soapEndPoint}}/Service.asmx
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
     <a:Action s:mustUnderstand="1">Retrieve</a:Action>
     <a:MessageID>urn:uuid:7e0cca04-57bd-4481-864c-6ea8039d2ea0</a:MessageID>
     <a:ReplyTo>
        <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
     </a:ReplyTo>
     <a:To s:mustUnderstand="1">{{soapEndPoint}}/Service.asmx</a:To>
     <fueloauth xmlns="http://exacttarget.com">{{accessToken}}</fueloauth>
  </s:Header>
  <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
           <ObjectType>Subscriber</ObjectType>
           <Properties>ID</Properties>
           <Filter xmlns:q1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="q1:SimpleFilterPart">
              <q1:Property>SubscriberKey</q1:Property>
              <q1:SimpleOperator>equals</q1:SimpleOperator>
              <q1:Value>{{subscriberKey}}</q1:Value>
           </Filter>
        </RetrieveRequest>
     </RetrieveRequestMsg>
  </s:Body>
</s:Envelope>

Note that by including ID as a property, this will return all custom Subscriber Profile Attributes that you have added. You just need to parse the XML response to get the attribute that you need.

<soap:Body>
    <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <OverallStatus>OK</OverallStatus>
        <RequestID>4d71d4e9-f954-45a7-8bd0-3153b44a07cf</RequestID>
        <Results xsi:type="Subscriber">
            <PartnerKey xsi:nil="true" />
            <ID>2976505</ID>
            <ObjectID xsi:nil="true" />
            <Attributes>
                <Name>sub_id</Name>
                <Value>123</Value>
            </Attributes>
        </Results>
    </RetrieveResponseMsg>
</soap:Body>
  • "Email Demographics" in your answer {{Contact.Attribute."Email Demographics".sub_id}} is Data Extension name right? – Gokul M Jul 11 '17 at 5:36
  • No, this is the Attribute Set name for the All Subscribers list (which contains Subscriber Profile Attributes). You will see this in your Contact Model within the 'Email Data' Attribute Group. – Eliot Harper Jul 11 '17 at 6:24
  • Glad I could help. And if you deem this answer worthy of awarding your assigned bounty, you will need to click the bounty award icon next to my answer to award it. – Eliot Harper Jul 11 '17 at 6:35
  • Awarded the bounty :-) – Gokul M Jul 11 '17 at 6:40
  • 1
    FYI, I might be wrong about the requirement to have an if/else block helper to test if a value exists. That definitely used to be the behaviour (last year) but Salesforce may have fixed that. Anyway, there's no harm to include it. – Eliot Harper Jul 11 '17 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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