How to use a Stored Procedure in K2?

  • 19 September 2016
  • 3 replies
  • 78 views

Userlevel 3
Badge +16

Hi,

 

Not used or accessed a Stored Procedure before, can anyone offer some advice plz?

 

I have access to a SQL Stored Procedure (not on the K2 Server, elswehere on a SQL Server) which i want to attached to a K2 Form and run on Initialization to populate some fields on a Form.

 

a) Can someone explain if i need to attach the Stored Procedure in Workspace? If so, how?

b) How do i pass a paramater (UserID) from K2 to the Stored Procedure, and then pull the results back into the K2 to display the fields returned?

 

The idea is, that when the form loads, I want to pass the logged-in UserID from the K2 form to the SQL Stored Procedure and from the results, populate a K2 List where the user picks a single row of Data (could be 1 or more rows returned by the SQL Stored Procedure) and then when the user selects one row,  then go ahead and fills in fields on the k2 form from what row i selected.

 

Can anyone advise?


3 replies

Userlevel 5
Badge +18

1.  You will likely have to create a stored procedure that does what you need and test it outside of K2


 


2.  If it does what is needed, you can register a SQL Server service instance against this database as per:


http://help.k2.com/onlinehelp/k2blackpearl/userguide/current/webframe.html#WS_SQL_01.html


 


3.  Below are also some information regarding stored procedures:


http://help.k2.com/onlinehelp/k2blackpearl/userguide/current/webframe.html#Stored_Procedures.html


 


4.  SmartObjects can be created from these stored procedure service objects, to be called on form/view initialize.

Userlevel 3
Badge +16

Thanks Tin, managed to use it.

 

 

Tin,
Your links are no longer active, could you provide updated links so I could reference. Trying to do this exact thing.

Reply