Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


ReturnP: this is the info page that the respondent lands once returned from the shelf, all data captured and appended into the hidden variables must be on a same page so you can recode it from the API

...

Code Block
languagejs
if (!IsInRdgMode()) {

    var link = encodeURIComponent(GetRespondentUrl('LandingLabel'));

    Redirect("https://survey.rose.conceptsauce.io?param_id=XXXXXXX&respondent_id=" + CurrentID() + "&link=" + link, true);

}

...

Get the survey ID from ParamID, Check if Api call was successful

Code Block
languagejs
//Get survey ID from Param ID -------------------------------------
var paramsCallObj = {
    event_type: "params_crud",
    action: "get_params",
    data: {
        params_id: cellParamID,
    },
};
var paramsCallStr = JSON.stringify(paramsCallObj);

var surveyIDcall = $.parseJSON(
    $.ajax({
        url: "https://better-params-api.rose.conceptsauce.io/api",
        type: "POST",
        data: paramsCallStr,
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("success id call");
            console.log(result);
        },
        error: function (error) {
            console.log(error);
        },
    }).responseText
);

//check if API call was succesful
var survey_id = "";
if (surveyIDcall.code == 200) {
    survey_id = surveyIDcall.data.params.survey_id;
}

...

Get the shelf details and append them into the hidden variables

Code Block
languagejs
//get summary ITEMS looked at
var reqSumItems = {
    event_type: "survey_data_request",
    action: "get_shop_shelf_summary_items_looked_at",
    data: {
        target: {
            survey_id: survey_id,
            respondent_id: respondent_id,
            block_id: "shelf",
        },
    },
};

var reqSumItemsStr = JSON.stringify(reqSumItems);

var resultAPIcall3 = $.parseJSON(
    $.ajax({
        url: "https://public-survey-data-api.rose.conceptsauce.io/api",
        type: "POST",
        data: reqSumItemsStr,
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("success api call Summary Items");
            console.log(result);
        },
        error: function (error) {
            console.log(error);
        },
    }).responseText
);


//recode all items looked at(bought and not bought, abe vsi4ki)
var itemsLookedAt = resultAPIcall3.data.items_looked_at;

var P1look = Confirmit.page.getQuestion("P1looked");
P1look.setValue(null);

var P1lookArr = [];

for (var p = 0; p < itemsLookedAt.length; p++) {
    P1lookArr.push(itemsLookedAt[p].sku);
}

P1look.setValue(P1lookArr);

...

Pass the selection in the redirect link

Code Block
languagejs
if (!IsInRdgMode()) {

    var link = encodeURIComponent(GetRespondentUrl('ReturnB'));
    var chosenParam = f('linkDisabled').get();
  

        Redirect("https://survey.rose.conceptsauce.io?param_id=PRMS01G3H5T63290RQZY2KG8250G53&respondent_id=" + CurrentID() + "&custom_params=" + chosenParam + "&link=" + link, true);
  }

...