Question regarding safe check of part of message + secondary question regarding embedded language #4568
-
Hello. Is there any way I can check for the existence of something like Also is there some kind of reference I can read to see what's possible in this input field ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The code you write is javascript running on the Rhino engine (which allows it to access java libraries, but you are not writing java code.) Rhino supports all of ES5 and some of ES6 and later. You can check which features are supported here https://mozilla.github.io/rhino/compat/engines.html. The version of Rhino you are using depends on your mirth version. To your first question a /**
Try to run a function that may throw an exception and return the function's return value. Accepts
either a default value or an error handler function in the event of an exception.
@param {Function} fn - function to run
@param {Any} onError - either a default value for when fn throws an exception or a callback
function that accepts the caught exception as a parameter
@return {Any} the return value of fn or the return value or onError or onError
*/
function tryit(fn, onError) {
var result;
try {
result = fn();
}
catch(e) {
if (typeof onError == 'function') {
result = onError(e);
}
else {
result = onError
}
}
return result;
} Then I call it like: var error = tryIt(() => msg['errors'][1], undefined); |
Beta Was this translation helpful? Give feedback.
The code you write is javascript running on the Rhino engine (which allows it to access java libraries, but you are not writing java code.) Rhino supports all of ES5 and some of ES6 and later. You can check which features are supported here https://mozilla.github.io/rhino/compat/engines.html. The version of Rhino you are using depends on your mirth version.
To your first question a
try
will work well. I use this Code Template: