Page 1 of 1
Table select in offline form
Posted: Wed Mar 05, 2014 11:57 am
by soapagent
I have a table in an offline form bound to an SQL statement.
I want the user to touch a row in that table and display another offline form based on the selected rows content.
I an online for I would set event parameters on the table load and retrieve them in the event handler.
I cannot find an example of this in the tutorials.
Is this possible?
Re: Table select in offline form
Posted: Wed Mar 05, 2014 12:56 pm
by Mark_Dale
What about Offline work with photos offline - LREX0307 /LREX0308
The detailer LREX0308 can access all the values for the current row that the user touched in LREX0307
* This example demonstrates a useful technique for handling List - Detailer programs (when Offline).
* This List program is able to call a Detailer offline program and give that program access to all the SQL FLD values available in this program, without any coding.
Or
Work with Order Headers LREX0321 / LREX0322
Or
Read an SQL FLD in a Script LREX0340 / LREX0341 (Under Other examples --> Advanced Examples --> How To -->Read an SQL FLD in a script )
Re: Table select in offline form
Posted: Wed Mar 05, 2014 4:01 pm
by soapagent
Thank you - I didn't make the mental leap from what was explained and what I was trying to do!
I have implemented the technique and I can see it is working. I am having trouble using FLD value in an SQL binding.
The following
#Com_Owner.Set_TextBox Name(STUDYR) Layout_Row(1) Layout_Col(1)
#Com_Owner.Set_Binding Name(STUDYR) Property(VALUE) Bindtotype(FLD) Bindto('STUDYR')
Displays the value I expect (10, 11 or 12)
But
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT ROWID, STDID, CALYR, STUDYR, CRSID, STDMSI, SCHID, SCHLNM, CRSLNM FROM StudentCourses WHERE STDID = &(GVAR:BOS_SO000_STDID_CT) AND STUDYR=&(FLD:STUDYR)')
Produces no output and no errors.
If I remove the STUDYR= clause I get a full listing with 10, 11 and 12 values.
A previous version using a GVAR to supply the value worked as expected,
Is this syntax incorrect for SQL use?
Re: Table select in offline form
Posted: Wed Mar 05, 2014 4:26 pm
by Mark_Dale
I think the syntax is ok, but in the SQL, when referring to a FLD STUDYR that is not in the SQL table being bound to the element, you have to explicitly specify which SQL table is being used.
e.g. (from LREX0322)
* Note that because this element is bound to the OrderLine SQL Table, if we want to refer to a FLD from the OrderHeader SQL Table, we have to refer to the FLD as &(FLD:OrderHeader.HeaderNumber)
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(TBL) Bindto('OrderLine')
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT ROWID,OrderNumber, OrderLine, ProductID, OrderLineValue, OrderLineQuantity, OrderLineStatus FROM OrderLine WHERE &(FLD:OrderHeader.HeaderNumber) = OrderNumber ')
Re: Table select in offline form
Posted: Thu Mar 06, 2014 11:23 am
by soapagent
Mark
I have changed the code to
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT ROWID, STDID, CALYR, STUDYR, CRSID, STDMSI, SCHID, SCHLNM, CRSLNM FROM StudentCourses WHERE STDID = &(GVAR:BOS_SO000_STDID_CT) AND STUDYR=&(FLD:StudentEntries.STUDYR)')
as suggested but it still does not work. Some observations.
1.The STUDYR value does work for the TEXTBOX binding.
2. Using the StudentEntries.STUDYR version in the TEXBOX binding causes a crash (developer console).
3. If I change SQL binding to, say, StudentEntries.STUDYRX (doesn't exist) there is no error thrown. So there could be a problem but no way of knowing what it is.
Any ideas?
Re: Table select in offline form
Posted: Thu Mar 06, 2014 1:44 pm
by Mark_Dale
Looking at Order Headers / Order Lines (LREX0321 /LREX0322), as a working example (I'm assuming it does work in your environment)
The key things are:
The calling program (Order Headers) LREX0321 does this:
* Note OrderNumber is passed as HeaderNumber
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(TBL) Bindto('OrderHeader')
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT ROWID,OrderNumber, OrderNumber AS HeaderNumber, CustomerID, OrderValue, OrderStatus FROM OrderHeader')
...
#Com_Owner.Set_Op_Form_Open Event(BOUND_TABLE.COL%7.CONTENT.OnClick) Name(LREX0322) Presentmode('Stack')
The called program (Order Lines) LREX0322 does this:
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(TBL) Bindto('OrderLine')
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT ROWID,OrderNumber, OrderLine, ProductID, OrderLineValue, OrderLineQuantity, OrderLineStatus FROM OrderLine WHERE &(FLD:OrderHeader.HeaderNumber) = OrderNumber ')
1. The call (set_Op_Form_Open) must use PresentMode('Stack') if the called program is to be able to access FLDs from the parent (caller) program.
2. The SQL Table name in &(FLD:OrderHeader.HeaderNumber) is the name in the parent's context - i.e. from this line in the parent:
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(TBL) Bindto('OrderHeader')
Are both those true in your example?
Re: Table select in offline form
Posted: Thu Mar 13, 2014 5:30 pm
by soapagent
Mark
I've got this working and it was my mistake (as I'm sure you guessed). I had the wrong value in TBL binding (didn't match the SQL).
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(TBL) Bindto('StudentCourses')
#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT... StudentCourses...)
I must admit though that I don't understand this syntax - it looks like we're giving a single property of an object two values?