Skip to main content

How to pass a field value into a query

Comments

3 comments

  • Official comment
    Megan Ellis

    Hi William,

    In the http.get URL in your business rule to populate Dropdown B, you'll need to pass a value to the variable ddlBranchDept. So your URL will looks something like "https://<server>:<port>/database/queryset/query?ddlBranchDept=" + DropdownA.value 

    Let me know if that makes sense! The business rule in this example shows this syntax.

    if (sc.value.length > 0) {
      eval ('x=' + http.get('http://localhost:8082/database/BIRT/ordersByCustomer?cnum=' + sc.value));

     

  • William C

    Hi Megan,

    I'm getting this error when my rule tries to run:

    ** Error: cannot find dependency named [resultSet] in rule [New Submission.SQL Query]

    Here is my rule code:

    /*member resultSet*/
    var event = form.load;
    var x;

    if (Boolean(ddlBranchDept.value)) 
      {
    eval ('x=' + http.get('http://localhost:8081/database/queryset/query?ddlBranchDept=' + ddlBranchDept.value));
      var opts= [];
      for (var i=0; i < x.resultSet.length; i++) {
        if (x.resultSet[i]) {
          opts[i] = x.resultSet[i].value + '=' + x.resultSet[i].label;
        }
      }
      ddlCostCenter.options = opts;
    }

    This doesn't have anything to do with the data being returned in JSON vs XML format, does it?

    0
  • Megan Ellis

    Hi William,

    Are the database columns you're pulling in the resultSet actually called 'value' and 'label'? If not you'll want to make sure you're referencing the actual column name. In this example the db column names are customerNumber and customerName:

     if (x.resultSet[i]) {       
                opts[i] = x.resultSet[i].customerNumber'=' + x.resultSet[i].customerName;    
            }  
     
    If 'value' and 'label' are the db column names, these are reserved words and frevvo won't be able to parse them from the json as is. The workaround is to encase the word in square brackets. See this documentation, which is for Google Connector but the same thing would apply here.
     
     
    0

Please sign in to leave a comment.