Javascript list of MxObjects

0
How can I return a list of objects using javascript? I created the following code (i’m not a programmer) but the list is empty (in my nanoflow). This is the code I wrote/found and modified. export async function GetReadPermission() { // BEGIN USER CODE const queryString = window.location.search; console.log(queryString); // ?state=&code=FAKECODE123&scope=read const urlParams = new URLSearchParams(queryString); const state = urlParams.get('state').toString() console.log(state); //state='' const code = urlParams.get('code').toString() console.log(code); //authorization code const scope = urlParams.get('scope').toString(); console.log(scope); //scope function getList() { return new Promise(function (resolve, reject) { var parameters = [state, code, scope]; var parameterlist = []; for(let i=0; i<3; i++){ mx.data.create({ entity: "MyFirstModule.url", callback: function(mxObject) { mxObject.set("Text", parameters[i]); parameterlist.push(mxObject); }, error: function(e) { reject("Could not create object:" + error.message); } }); } resolve(parameterlist); }); } return Promise.resolve(getList()); // END USER CODE } the variables state, code and scope are ok. They contain the correct data but I can’t figure out how convert these into mxObject so that i can return a list of MxObjects containing these 3 variables.
asked
1 answers
4
export async function GetReadPermission() {
	// BEGIN USER CODE
	const queryString = window.location.search;
	console.log(queryString);
	// ?state=&code=FAKECODE123&scope=read
	const urlParams = new URLSearchParams(queryString);	
	const state = urlParams.get('state').toString()
	console.log(state);
	//state=''
	const code = urlParams.get('code').toString()
	console.log(code);
 
	return new Promise((resolve, reject) => {
           mx.data.create({
		      entity: "MyFirstModule.url",
				callback: function(mxObject) {
	                for(let i=0; i<3; i++){
			           mxObject.set("State", state);
					   mxObject.set("Code", code);
					   mxObject.set("Scope", scope);
                    }
					resolve(mxObject);
				},
				error: function(e) {
					reject("Could not create object:" + error.message);
				}
			});
      }));
	// END USER CODE
}

 

answered