1

I have a custom Journey Builder activity. What I would like to do, is display a list of fields present in the Entry data source when the user is configuring the activity.

To do this, I have assumed that during the initActivity trigger from Postmonger I would:

  1. Request Endpoints
  2. Request Tokens
  3. Request Trigger Event Definition

This would then give me the Event Key, Endpoints, and tokens. I assume then that I can use the /interaction/v1/events REST route https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/postEvent.htm to retrieve a list of data fields in the Event DE.

My code for this:

connection.on('requestedEndpoints',function(endPoints){
    
    console.log("****** ENDPOINTS ******");
    
    connection.on('requestedTriggerEventDefinition',function(eventTrigger){
        
        console.log("****** EVENT ******");
        
        connection.on('requestedTokens',function(tokens){
            
            console.log("************ REQUESTED TOKENS NESTED ****************");
            console.log(endPoints);
            console.log(eventTrigger);
            console.log(tokens);
            
            $.ajax({
                url:endPoints.fuelapiRestHost + 'interaction/v1/eventDefinitions/Key:' + eventTrigger.eventDefinitionKey,
                method:'GET',
                headers:{Authorization:'Bearer ' + tokens.token},
                success:function(data,textStatus,jqXHR){
                    console.log("******************** EVENT REQUEST RESULT ******************");
                    console.log(data);
                }
            });
            
        });
        
        connection.trigger('requestTokens');
    });
    
    connection.trigger('requestTriggerEventDefinition');
});

Obviously though, because this is done on the front-end, I'm getting CORS policy errors.

But; I don't see any routes documented that would be called prior: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-app-development.meta/mc-app-development/custom-activity-config.htm to allow me to prepare the event fields ahead of time.

Does anyone know how I can accomplish this.

1

You can request the event definition key using the trigger that you have listed above (with some simple modifications). This will get the event definition key and set as a variable that you can use to pass in your payload to the back-end. To generate your tokens, just decode the JWT and parse out your token from there.

  connection.on("requestedTriggerEventDefinition", function (
    eventDefinitionModel
  ) {
    if (eventDefinitionModel) {
      definition = eventDefinitionModel;
      eventDefinitionKey = eventDefinitionModel.eventDefinitionKey;
    }
  });
| improve this answer | |

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.