Customer Journey Configuration

From SMTX Wiki
Jump to navigation Jump to search

Below are some examples for referring to fields in the customer journey

Customer Journey References

These references are examples for retrieving data from the Customer Journey

Moments

Planned Start Date

#MOMENT-name-of-moment||date||#

Actions

Planned Start Date

#ACTION-name-of-action||date||#

Form instanceid of the Concept form created

#ACTION-actionname||output.forminstanceid||#

Submitted Form Values

#ACTION-actionname||output.fieldvalues.datum.value||#

Variables

#VARIABLE-name-of-variable||value||#

Special variables

When a variable with the internallabel "widget-header-text" is created, the contents of this variable will be displayed at the top of the widget

Common Form References

#REPLACE-FORMFIELD-InternalLabel||#
#REPLACE-FORMFIELD-InternalLabel||Column#

Common Process References

Customer Journey process start date

#REPLACE-STEP-PROCESS-DateStarted-yyyyMMdd#

Customer Journey process id

#REPLACE-STEP-PROCESS-Id#

Javascript Examples

Below are some common used scripts that can be reused in your projects

Check if moment already has a startdate, if not set it

var currentvalue = '#MOMENT-dossier-klaar||date||#';
if (currentvalue) return currentvalue;
if ('#VARIABLE-dossier-klaar||value||#' === 'yes') 
 {
   return CommonInterface.utcDateToString(new Date(), "yyyyMMddHHmmss");
 }

Script to execute in a form when it is used to collect additional data

var forminstance = JSON.parse(g_forminstance_string);
var processinstanceidformfields = forminstance.values.filter(function (val) { return val.internallabel === "hidProcessInstanceId"; });
var processinstanceid = 0;
if (processinstanceidformfields.length > 0) {
  processinstanceid = +processinstanceidformfields[0].value;
}
if (processinstanceid) {
  WorkflowInterface.setVariableValue(processinstanceid, "FormInstance_" + forminstance.id, g_forminstance_string);
  CommonInterface.callWebservice("BZ - Klantreis - Check create form instance actions", { ProcessInstanceId: processinstanceid, CheckIsProcessing: "true" });
  return "Bedankt voor het invullen, we gaan er mee aan de slag";  
} else {
   return "ProcessInstanceId not found";
}

Update variable with webservice

Name of the webservice: ssproot/customer-journey-app/buttonactions/editvariables
retrievesinglevalue
Input plain text: ProcessInstanceId=#PROCESSINSTANCEID||URL#&VariableNames=#VARIABLENAME||URL#&VariableValue_#VARIABLENAME||URL#=#VARIABLEVALUE||URL#&HashCheck=#HASHCHECK||URL#
Input fields:
 ProcessInstanceId (ticket id)
 VariableName (Name of the customer journey variable)
 VariableValue (New value to set)
 HashCheck (CommonInterface.getHash('sha512', processinstanceid + 'actionbutton_editvariables' + '_' + variablename + StudioInterface.getVariableValue("hash-check-salt")))

Update variable with function

When executing a javascript within the customer journey, you can use this function to update a variable, with using the webservice solution mentioned above:
updateVariable("widget-header-text", "this is the new value");

Retrieving variable value without placeholder

Normally you can use the variable placeholder to refer to the value of a variable. Alternatively you can also use the function below to get the contents of a variable:
var thevariablevalue = getVariableValue("widget-header-text");