Is it possible to pass through parameters to the CloudCode task? And how can I do it from the view.js?

Is it possible to pass through parameters to the CloudCode task? And how can I do it from the view.js?

Hi @sisa-zaza ,

It is possible to pass parameters to a CloudCode task from any view’s .js file. The example code below will send the parameters params to the CloudCoude task called cloudcode_task.

function callTask() {
    var task = "cloudcode_task";
    var params = {
        "foo": "bar",
        "one": 1
    };
    var result = CloudCode.callTask(task, params);
}

Please see the JourneyApps Documentation for more information on triggering a CloudCode task from the app.

Hi @nidene ,
Would the same apply to a webtask which should return html to the view.js?

I want to send a object id to a webtask which will generate a html using the details on that specific object and return the html to the view.js in which it will be used to display on the app

Hi @sisa-zaza ,

It is possible to return your function’s result from a CloudCode task and then use it in your view.js but it is not possible to build a dynamic xml view from the view.js. You might need to explore our HTML bridge component if you would like to build dynamic HTML pages.

Here are some resources:

I see that we have this existing idea on our product board that might be useful for what you would like to achieve. Please feel free to comment on that idea or please share your idea with us by submitting a new idea.

Hi @nidene ,

Yes Im using the HTML Bridge as:

on the view I want to access “https://your_custom_doman.poweredbyjourney.com/get_dynamic_results” but pass through a parameter like a user id and get the report for that user which was created using html to display on the app

Hi @sisa-zaza ,

I think I understand now what you would like to accomplish, thank you for the additional details. Please take a look at this existing forum post as the original poster sees that for a GET request to a CC webtask, the easiest way to pass parameters is using URL parameters, so in your case something like https://your_custom_doman.poweredbyjourney.com/get_dynamic_results?objectId=11111-11111-11111-11111: