0

I need to get the JourneyId as InArgument during the execution of a Custom Activity. But I cannot find how to get it in Postmonger event reference or in the list of properties of the Journey Context.

Please, can somebody help me?

Thanks in advance

1 Answer 1

2

You can retrieve the journeyId during the execution of the journey. In your /execute page, you just need to retrieve directly 'journeyId' in the requested post data, not in the inArguments.

Here is an exemple of execute page hosted in a CloudPage :

First Solution

<script runat="server">
Platform.Load("Core","1.1.1");
 var jsonpost = Platform.Request.GetPostData('utf-8');
 var json = Platform.Function.ParseJSON(jsonpost);
 var JourneyId = json.journeyId;
 var ActivityId = json.activityId;
 var ContactKey = json.keyValue;
 var formInputs = json.inArguments[0];
</script>

Updated Solution

I found that the JourneyId posted in the request was in fact the VersionId of the journey. Meaning that it changes on each new version. To get the JourneyId you will need to retrieve it from _Journey Data view using the VersionId.

<script runat="server">
Platform.Load("Core","1.1.1");
 var jsonpost = Platform.Request.GetPostData('utf-8');
 var json = Platform.Function.ParseJSON(jsonpost);
 var VersionId = json.journeyId;
 var ActivityId = json.activityId;
 var ContactKey = json.keyValue;
 
 //Get JourneyId 
 var JourneyRows = Platform.Function.LookupRows('_Journey', 'VersionID', VersionId); 
 var JourneyId = JourneyRows[0]["JourneyID"] ? JourneyRows[0]["JourneyID"] : VersionId;
 json.inArguments[0].journeyId = JourneyId; //update journeyId attribute in inArguments payload
 json.inArguments[0].versionId = VersionId; //add versionId attribute in inArguments payload

 var formInputs = json.inArguments[0];
</script>

You must log in to answer this question.

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