3

Hi I need a client side validation in my custom activity.

I have a field called name, I want it to be required. So When user clicks the done button in the iframe it will not push through and show an error message. Is this possible in postmonger event reference?

This is my code in reference to clicking the done button

connection.on('clickedNext', save); //Save function within MC

    function save() {

    let inArgs = payload['arguments'].execute.inArguments;

    if(eventDefinitionKey) {
        $.each(inArgs, function (index, inAug) {
            $.each(inAug, function (key, val) {
                inAug[key] = val.replace("eventDefinitionKey", eventDefinitionKey);
            });

            inAug['journeyStepCode'] = getJourneyStepCode();

            if(authTokens && authTokens.token){
                inAug['token'] = authTokens.token;
            }

        });
    }

    payload['metaData'].isConfigured = true;
    console.log(JSON.stringify(payload));

    connection.trigger('updateActivity', payload);
}

is there a Postmonger Events Reference where in if a field is null it will not push through and show an error message?

something like

if(!getJourneyStepCode()){
  //go back
  //show error message
}
1
1

You can show the error message using any Javascript DOM/CSS manipulation method (it looks like you are already using JQuery so you have a full set of options). Then just send the "ready" event to let JB know that configuration is not done yet :

if(error) {
    // display an error message, highlight form field... Anything you can do with client-side JS

    connection.trigger('ready');
} else {
    // update the payload with your custom parameters

    payload['metaData'].isConfigured = true;
    connection.trigger('updateActivity', payload);
}

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.