Quantcast
Channel: Mendix Forum Questions
Viewing all articles
Browse latest Browse all 83469

Return MxObject from javascript action

$
0
0
Hi, I’m trying to do some calculations and to return a MxObject afterward. I’m not that experienced in javascript but I’ve come up with some code but my object seems to be empty. Anyone who could help? export async function GetGeoFencee(name, description, afstand, latitude, longitude) { // BEGIN USER CODE const promise = createObject(name); let meter = 0.0000089; let coef = afstand * meter; //Calculating 4 points //point 1 let lat1 = latitude + coef; let long1 = longitude + coef / Math.cos(latitude * 0.018); //point 2 let lat2 = latitude + coef; let long2 = longitude - coef / Math.cos(latitude * 0.018); //point 3 let lat3= latitude - coef; let long3 =longitude + coef / Math.cos(latitude * 0.018); //point 4 let lat4 = latitude - coef; let long4 = longitude - coef / Math.cos(latitude * 0.018); //Stringbuilder let arraystring = `((${lat1},${long1}),(${lat2},${long2}),(${lat4},${long4}),(${lat3},${long3}))` //CreateObject function createObject(name) { return new Promise((resolve, reject) => { mx.data.create({ entity: "MyFirstModule.GeoFence", callback: function(mxObject) { mxObject.set("Name", name); resolve(mxObject); console.warn(mxObject); }, error: function(e) { reject("Could not create object:" + error.message); } }); }); } // END USER CODE  

Viewing all articles
Browse latest Browse all 83469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>