Nanoflow error: undefined is not an object

0
Hey guys I am super stuck. I keep running into this error when trying to update (MxObject.set) an mendix object that is passed to a Javascript Action as a parameter, and I’m not entirely sure why it’s happening. It’s passing checks I’ve put into place checking to see if it’s undefined, but it’s still throwing this ‘undefined’ error. I’m kinda new to some of the deeper intricacies of javascript and especially javascript within Mendix, so any help will be welcomed. Some additional information: - I am using a log action before hand to check and see that the object I’m passing in to the action isn’t empty, and it isn’t empty. - Mendix version is actually 8.4.1 (I didn’t see that as an option in the drop down. Also, ‘Javascript Action’ wasn’t an option in the Category drop down :/) - I am at my wits end Here is the error:   An error occurred while executing On click at NativeMobile.Home_Native.actionButton1: undefined is not an object (evaluating 'u.set("friendlyError",t.stack).set') http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:825:1174 Oe@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:370:11643 s@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:370:11348 P@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:826:133 f@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:117:155 http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:117:882 y@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:122:657 C@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:122:1021 callImmediates@http://192.168.0.33:8080/n/index.bundle?platform=android&dev=false&minify=true:122:3216 callImmediates@[native code] Here is the code causing the problem:   console.log(authObj.get("client_id")); if (authObj !== undefined) { authObj.set("friendlyError", error.stack) .set("errorMessage", error.message); } else { ; } return authObj; ^ This isn’t the entirety of the code, just a snippet, but I believe this is the section throwing the issue. If you wanna see the rest, please let me know.
asked
1 answers
3

To check for undefined in javascript use

if ( typeof authObj != 'undefined' )

Also, It is not possible to chain multiple set commands:

authObj.set("friendlyError", error.stack)
.set("errorMessage", error.message); // throws error because set function returns undefined


//correct

authObj.set("friendlyError", error.stack)
authObj.set("errorMessage", error.message);

 

answered