NetTalk Central

Author Topic: Getting values from a parent to determine hiding fields in child  (Read 2740 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Windows7Ultimate 64bit Clarion63_9056 NT545
When I INSERT a new Parent
In my parent form I have a selection from a product list
On the same form I have a browse of insured items
Once I have selected a product I select insert on the insured item browse
Based on the productID selected in the parent I want to hide certain fields in the insured items form.
The problem seems to be that at this point the parent record has not been written to the table so if I prime the child with INS:ProductID = APP:ProductID the value is zero
I tried this
ACCESS:Application.Open()
ACCESS:Application.UseFile()
APP:ApplicationID = INS:ApplicationID
ACCESS:Application.FETCH(APP:PK_ApplicationID)
INS:ProductID = APP:ProductID
p_web.SetSessionValue('INS:ProductID',INS:ProductID)
ACCESS:Application.Close()
 in preinsert end with no luck (because there was nothing written to the table yet)
I then tried adding
adding
p_web.SSV('NewProductCode',p_web.GSV('APP:ProductID'))
p_web._trace('application_form newpeoductcodevalue ' & p_web.gsv('NewProductCode'))

to the server code of the parent productid selection but the trace value is blank
had this worked I would then have put this code in the preinsert end embed of the child

IF p_web.GSV('INS:ProductID') = 0
    INS:ProductID = p_web.GSV('NewProductCode')
    p_web.SSV('INS:ProductID',INS:ProductID)
    p_web._trace('insureditem_form productid cannot be zero ' & p_web.GSV('INS:ProductCode'))
END

What should I try to have the productID available to me within the child form?
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Getting values from a parent to determine hiding fields in child
« Reply #1 on: January 23, 2012, 11:17:33 PM »
Hi Terry,

Maybe you should use "send new value to the server" and then some server side code to keep the data you need in a sessionvar.

Cheers,
Rene
Rene Simons
NT14.14

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Getting values from a parent to determine hiding fields in child
« Reply #2 on: January 24, 2012, 12:05:24 AM »
If the parent ID is being auto-numbered, then you should do it in PostInsert, not PreInsert or ValidateRecord.

cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Getting values from a parent to determine hiding fields in child
« Reply #3 on: January 24, 2012, 12:57:24 AM »
Hi bruce
I am getting the parentID, what I need is the productID which is selected while the parent is still in insert mode before saving.
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Getting values from a parent to determine hiding fields in child
« Reply #4 on: January 24, 2012, 01:05:44 AM »
That should be in the Session Value of that field.
Unless you're overwriting that session value in your code.

>> I prime the child with INS:ProductID = APP:ProductID

rather prime the child with INS:ProductID = p_web.GSV('APP:ProductID')