You are viewing limited content. For full access, please sign in.

Question

Question

retrieve data from stored procedure

asked on November 18, 2016 Show version history

I am attempting my first form using datasources. I have created a stored procedure that returns employee names and several other data about the employee. Using a look-up rule I have been able to populate a drop-down with the employee names. What I want is that when a name is selected in the drop-down the other fields such as job title are populated. I may not have searched for the right phrase but I haven't seen how this is done. I am a newbie so I'm going to need detailed steps on how to accomplish this.

0 0

Answer

SELECTED ANSWER
replied on November 18, 2016

Yeah, that was my realization and subsequent edit: if the existing stored procedure takes something as input and returns all the values, you'll need a stored procedure which takes the name as a parameter.

0 0

Replies

replied on November 18, 2016 Show version history

Hi Leigh,

I'm not sure about the specifics of your process, but it sounds like you may need a combination of lookup rules in Forms:

  1. Lookup rule with some unspecified match condition (or possibly none at all) that populates the dropdown list with the employee names from the stored procedure.
  2. Lookup rule which matches the employee name and populates the other fields with the additional data (e.g. job title).

Then Rule 1 prepares the dropdown for the user to pick an employee, and once they select an employee, Rule 2 kicks in and fills out the rest of the information.

Hope this helps! If you need a more detailed example of implementing this, let me know.

Edit: Actually thinking about it, it may be that your stored procedure as-is need only return the employee names and not the other data. (Unless of course, you reuse this in a number of ways elsewhere.) For Rule 2, you would need another stored procedure that can take the employee name as the input and return the other values. If you can set up a table or view with all of the information, you could probably use that for both lookup rules instead of needing separate stored procedures for each one.

0 0
replied on November 18, 2016

FYI, if you are creating a second lookup based on the return value of the first lookup, if you are using forms v 10.1 you must apply the Update 3 Patch for this to work.

0 0
replied on November 18, 2016

If this is a reference to SCR 148040 in the list of changes, that was for specific scenarios such as the following:

  1. Rule 1: Match FieldA, Fill FieldB with multiple possible values
  2. Select value for FieldB.
  3. Rule 2: Match FieldA, Match FieldB, Fill FieldC with some values.

Since Rule 2 had multiple match conditions, the Auto-fill button would be needed to advance the lookup rule. However in this circumstance, the Auto-fill button would not show. It's possible this could be the case here, but the description in the KB article makes it seem like any chain of Match -> Fill -> Match would fail, which is not entirely accurate.

That said, Update 3 did include numerous fixes to conflicts which could arise with combinations of lookup rules, field rules, JavaScript, and Calculations in form fields, so of course we would still recommend to update to the latest version.

0 0
replied on November 18, 2016

Am I going to need a second sp to populate the other fields using the selected name as a parameter?

0 0
SELECTED ANSWER
replied on November 18, 2016

Yeah, that was my realization and subsequent edit: if the existing stored procedure takes something as input and returns all the values, you'll need a stored procedure which takes the name as a parameter.

0 0
replied on November 18, 2016

Thanks for the input. Makes sense needing the second sp.

0 0
replied on November 30, 2016

Hi James,

Just on this process, if you are using the two SPs for the lookup rules i.e. as per the 3-step process you detailed in your response to Steve, is the Autofill button always going to be required to populate FieldC regardless of whether the Rule2 lookup is only returning a single record?

Thanks,

Mike

0 0
replied on November 30, 2016

Hi Mike, the Autofill button appears whenever there are multiple match conditions, regardless of how many fields are being populated. [reference] That said, it is possible to use CSS/JavaScript to "hide and automatically click" the Autofill button, there are various threads on Answers where this is accomplished.

1 0
replied on November 30, 2016

Thanks very much James.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.