What variant of JavaScript is used in defining business rules?

Comments

6 comments

  • Avatar
    Prajakta

    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
    Comment actions Permalink
  • Avatar
    James Johnson

    Thanks. I'm not familiar with the object, http.  Where can I find documentation on the http.post method?

    0
    Comment actions Permalink
  • Avatar
    Prajakta

    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.zip
    0
    Comment actions Permalink
  • Avatar
    James Johnson

    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
    Comment actions Permalink
  • Avatar
    James Johnson

    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
    Comment actions Permalink
  • Avatar
    Prajakta

    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
    Comment actions Permalink

Please sign in to leave a comment.