What variant of JavaScript is used in defining business rules?
I've noticed that object such as window and document do not seem to be supported by the JavaScript used in defining business rules. Also, http.get seems to be unique to this variant of JavaScript. Is there a http.post? What variant of JavaScript is being used?
-
The JavaScript in frevvo business rules executes on the frevvo server. So it is not client side JS that would enable accessing window, document, etc. objects.
http.get in the rules expects a JSON response. So whatever web service you are calling via http.get in rules needs to return JSON results. Please see this documentation which explains this in more details.
0 -
Thanks. I'm not familiar with the object, http. Where can I find documentation on the http.post method?
0 -
Following three http.post methods are available:
- eval('x=' + http.post('URI?foo=bar'));
- eval('x=' + http.post(URI, jsonPayload));
- eval('x=' + http.post(URI, jsonPayload, jsonHeaders, ));
They do not support anything other than JSON.
Attached is a sample form.
POSTDataFromARule_form.zip0 -
Thanks. Where can I find additional documentation on the http object? Is this object an object from some JavaScript library or a Frevvo custom JavaScript object?
0 -
Also, how can I create a jsonPayload object? var jsonPayload = {prop : 'abc'}; is valid JavaScript but produces the following error in frevvo:
Form or Rule Level Validation Issue: Suggested directive for unrecognized members. Please check detailed errors before using.
/*member prop*/
Line 4, character 28: var jsonPayload = {prop: 'abc'};
Unexpected /*member 'prop'.0 -
frevvo business rules use Rhino: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino. It is possible that we might change this, though not likely.
Adding /*member prop*/ at the top of your rule should remove that validation error. Please see this documentation about validation directives.
Or else use:
var jsonPayload = "{prop : 'abc'}";
instead of:
var jsonPayload = {prop : 'abc'};
0
Please sign in to leave a comment.
Comments
6 comments