Can forena do following:

I have external sql serv db and I want to send a param and show the results or show custom message if the parameter is not in the db. The parameter would be a cust id or something similar.

Comments

johnger created an issue.

metzlerd’s picture

You shoul be able to do this with the following snippet of code in your .frx file:

  <p frx:if="!{parm.cust_id}">Without a customer ID we cannot display your information</p> 

The snippet should be placed outside of any elements containing frx:block attributes, so that it always displays.

metzlerd’s picture

Or if you're really concerned with a customer id being in the database, invent a block called "customer_info" or something like it that has some relevant SQL such as:

SELECT customer_id, customer_name from customers where customer_id=:cust_id

Then embed that block in your reports, using named data contexts to display a message when the customer is not in the database.

  <div frx:block="mydata/customer_info" frx:foreach="*" id="customer_info">
     <h2>{customer_name}</h2> 
  </div>
  <div frx:if="!{customer_info.customer_id}">
     <p>We could not find that customer in our database</p> 
  </div> 
johnger’s picture

I thought I watched one of your screencast's on youtube where you did not leave the parameter field blank in the module report creation under drupal.

Basically, I am wanting to present a text box and have the customer input their id and then display the data if they are in db. I hope this makes sense?

Btw, thanks for taking time to answer and help.

metzlerd’s picture

Take a look at:
http://forenasolutions.org/reports/help.reportingfrx#parameters

In that example you create a required parameter, which may or may not have defaults (WA in this case). But the establishment of a required parameter is how I would achieve what you are describing. Then use the techniques above to create the message you want to use when there is no matching cust_id in the database.

I think that's what you're asking for, but am a bit uncertain.