NetTalk Central

Author Topic: Conditional tab display on memory form  (Read 4577 times)

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Conditional tab display on memory form
« on: November 25, 2012, 03:06:22 PM »
Bruce,

     As a second experiment for the multi-selection issue I posted about, I have tried another idea.  I created a memory form that has a series of tabs, labeled General, Skin, etc.  I want to use this form as a pseudo look up form, from a button added next to a form field.  Each tab on the memory form has the tab condition set to:

              p_web.GSV('ROStab') = 'General', p_web.GSV('ROStab') = 'Skin', etc.

     I call the memory form from a button on a standard form.  I have tried setting the session variable in many different embeds of these buttons, using the following:

              btnGeneral      p_web.SSV('ROStab', 'General')
              btSkin              p_web.SSV('ROStab', 'Skin'), etc.

     Currently I have the code in the "Add server side code here" embed.  It works but I find I must click the calling button twice to get the expexted effect, which is to unhide the General tab when the btnGeneral button is clicked, or unhide the Skin tab when the btnSkin is clicked.
     I have also tried passing "p_web.SSV('ROStab', 'General')" as a parameter by filling in the parameter field on the OnClick tab of the template.  This has inconsistent results.  In my testing I set this parameter for just the first two buttons, General and Skin.  The session variable always seems to contain the value "Skin".

     Do you have any suggestions to help resolve these two issues?

Thanks,

Jeff



         

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11252
    • View Profile
Re: Conditional tab display on memory form
« Reply #1 on: November 25, 2012, 10:17:45 PM »
example required. Your setup is too complex to comment just on what you've written.

cheers
Bruce

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Conditional tab display on memory form
« Reply #2 on: November 26, 2012, 08:09:16 AM »
Bruce,

     I have attached an example app.  It is a modified version of web33.  On the mailboxes form I added a new testtext field and buttons 1 and 2.  In addition I added a new TabMemoryForm procedure, which has two tabs labeled General and Skin.

     The idea is that buttons 1 and 2 call the TabMemoryForm procedure, passing a session variable called 'ROStab'.  I pass this in the parameter field of each button as follows:

button 1:  p_web.SSV('ROStab', 'General')
button 2:  p_web.SSV('ROStab', 'Skin')

     The tabs on the TabMemoryForm have the tab condition set as follows:

General tab:  p_web.GSV('ROStab') = 'General'
Skin tab:        p_web.GSV('ROStab') = 'Skin'

     So, the final effect I expect is that when button 1 is clicked, the TabMemoryForm should appear with the General tab visible.  Button 2 should call the form with the Skin tab visible.  However, both buttons call the form with the skin tab visible.
     I have also tried setting the session variable in various embeds of each button.  When I do this I find I must click each button twice to get the proper tag to appear. 
     So the issue is if the parameter is passed properly or which embed should be used to get the desired effect?

Thanks,

Jeff

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11252
    • View Profile
Re: Conditional tab display on memory form
« Reply #3 on: November 26, 2012, 11:19:11 PM »
>> I pass this in the parameter field of each button as follows:

button 1:  p_web.SSV('ROStab', 'General')
button 2:  p_web.SSV('ROStab', 'Skin')

this is wrong.

parameters are in the url format - ie name=value&name=value and so on.
in your case
'ROStab=General'
and
'ROStab=Skin.'

Then in the form you need to "remember" the parameters, by moving them into the Session Value.

p_web.StoreValue('ROStab')

this can go at the top of the GenerateForm routine.

>>  I have also tried setting the session variable in various embeds of each button.  When I do this I find I must click each button twice to get the proper tag to appear. 

buttons can't do "2 things in order". They can either fire a URL, or run server-side code. But if you do both the _order_ in which they execute is unknown. So one cannot depend on the other. (which is why it works the second time.)

Cheers
Bruce


kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Conditional tab display on memory form
« Reply #4 on: November 27, 2012, 12:51:57 PM »
Bruce,

     Excellent!  That worked great.  Now I'm placing check boxes on the various tabs, with the true value set to 1 and the false value set to 0.  The idea is to have the patient check these and then send text to the target text control on the calling form.  I have placed the following code in the SaveButtonSet Save embed:

If p_web.GetValue('ROStab') = 'General'
    ROSText = ''
    If p_web.GSV('GEN_NONE') = 1
        ROSText = 'NONE'
    Else   !If p_web.GetValue('GEN_NONE') = 0
      If p_web.GSV('Recent_weight_loss') = 1
        ROSText = 'recent weight loss'
      End
      If p_web.GSV('Recent_weight_gain') = 1
        ROSText = Clip(ROSText)&', '&'recent weight gain'
      End
      If p_web.GSV('Weakness') = 1
        ROSText = Clip(ROSText)&', '&'weakness'
      End
      If p_web.GSV('Fatigue') = 1
        ROSText = Clip(ROSText)&', '&'fatigue'
      End
      If p_web.GSV('Fevers') = 1
        ROSText = Clip(ROSText)&', '&'fevers'
      End
      If p_web.GSV('Chills') = 1
        ROSText = Clip(ROSText)&', '&'chills'
      End
      If p_web.GSV('Poor_appetite') = 1
        ROSText = Clip(ROSText)&', '&'poor appetite'
      End
      If p_web.GSV('Sleep_poorly') = 1
        ROSText = Clip(ROSText)&', '&'sleeps poorly'
      End
    End
    !ROS:GENCOND = Clip(ROSText)
    p_web.SSV('ROS:GENCOND', Clip(ROSText))
End

     This seems to work in reverse the way I have it now.  That is if I select the None check box, the other items are dropped into the target field.  If I do not select none but select other checkboxes, None is sent to the target.  I have read other posts and know that the session variable ffor the check box should be used.  Also see that empty (0 or false) checkboxes are not posted so these cannot be tested.  Can you help me once again?

Thanks,

Jeff

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Conditional tab display on memory form
« Reply #5 on: November 27, 2012, 03:25:46 PM »
Bruce,

     I think I may have this now.  The key was a statement you made in another post:

"If the checkboxes are completely static, then thier values will be in the Value queue when a form is saved."

I was trying to check for these values in the called form.  Knowing that the values are in the queue upon saving, I then moved my code to the GotFocusBack embed of the calling form.  Seems to work as I need it to.  What do you think?  Is this the best way to approach this?

Thanks,

Jeff

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11252
    • View Profile
Re: Conditional tab display on memory form
« Reply #6 on: November 27, 2012, 09:22:36 PM »
On thing that stands out as being wrong is;


If p_web.GetValue('ROStab') = 'General'

this should be


If p_web.GetSessionValue('ROStab') = 'General'

Because the parameter was stored in the SessionQueue using p_web.StoreValue('ROStab'), we can access it from the session queue. We can't access it from the value queue in that embed point (or lots of other embed points) because different embeds occur on different threads.

The rule is to store parameters, and then just use the SessionValue after that, not the Value.

Otherwise the code looked ok. With regards to location;

>>  I have placed the following code in the SaveButtonSet Save embed
...
>> I then moved my code to the GotFocusBack embed of the calling form.

I'm not sure when (specifically) you want this code to run. When the user clicks on SAVE?
Or after some other action?

Cheers
Bruce





kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Conditional tab display on memory form
« Reply #7 on: November 28, 2012, 08:08:56 AM »
Bruce,

I am now using

        If p_web.GetSessionValue('ROStab') = 'General'

The code sample I sent was an old version, one of many things I was trying. 

My original intent was to run the code when the user clicked on Save from the pop up memory form.  I have now placed that code in the GotFocusBack embed of the calling form.  All this works perfectly now (well, as far as I can tell at this point!).  Thanks for all your help.

Jeff

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11252
    • View Profile
Re: Conditional tab display on memory form
« Reply #8 on: November 28, 2012, 10:18:33 AM »
Hi Jeff,

If you want to embed the code in the form itself, then check either the ValidateRecord routine (this'll have before the record is written to disk) or the PostInsert / PostUpdate routines for after the disk write.

cheers
Bruce