In Native how to Export an object to JSON

In native you can not call ExportToJSON. I want to export an object to JSON and pass it along to the body-parameter of the call NativeRest.CallRestService. The module NativeRest has no javascript-action for this: What is the best way to generate the JSON form my object in Native?  
2 answers

I would suggest a javascript action call.

You set the required object (mxObj) as parameter, and set the return value as string.

Then in the code you process the object and convert the result into a string.


* @param {MxObject} mxObj

* @returns {Promise.<string>}


export async function JavaScript_action_CreateJson(mxObj) {



    // create the result object

    var result = {};


    // dynamicly read all attirbutes and set the attibute name and value to our result object


        .forEach(function(attributeName) {

            result[attributeName] = mxObj.get(attributeName);



    // convert our result to a string and return it

    return JSON.stringify(result);




Then in your, calling nanoflow you get this

In my example i set the returned json string as an attribute of my entity, but offcourse you can use it right away to send it over an API call.

I am not sure if this is the best way to do so, but at least it will do what you want it to do.


Succeeded today in exporting a list of objects to a JSON-string by upgrading to Mx 8.8.1, having a nanoflow call a microflow and have that microflow call an Export-to-JSON activity for a non-persistent entity. So I will be upgrading our app and avoid creating our own javascript-export-to-JSON widget.