NetTalk Central

Author Topic: p_web.gsv() on Update Form does not work? (with EXAMPLE now)  (Read 4488 times)

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« on: February 24, 2011, 06:35:20 AM »
Here's the situation:

The file for the update is Quotes.

In the form I set locals for files called Client, Sections and Details.

On insert, all the values and Requireds have to be entered, and if this checks out I get the session values and create the approriate Client, Sections and Details records.

Now on update, in the PreUpdate -> Start embed point I get the values from the Client, Section and Detail files and set their Session Values.  The Update screen loads perfect.  I do not allow a change on the Section Code in the update (so I make it ReadOnly if loc:Act <> Net:InsertRecord).  Some comments and stuff that check p_web.gsv('SectionCode') display correctly.

Now in the Validat All Routine when you press the Save Button, I do a p_web.gsv('SectionCode') and it returns zero, and not 4 for instance as I set it in the beginning.  

I tested a bit around this and it seems only values that you change filters through to the Validate All Routine.  

Any ideas?  Still NetTalk 5.15 and Clarion 6.3.

Thanks
Charl



« Last Edit: April 12, 2011, 02:28:47 AM by charl99 »

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work?
« Reply #1 on: April 11, 2011, 06:46:12 AM »
I am still having this problem.

Let's try this example ter illustration:

Somebody (a broker) ask for a policy quote on the web, status='Broker Quote'.

A user with the 'rights' to Approve the quote, then change the status to 'Approved' (and sometimes modify it). 

Once it is approved the the broker can then go and 'Accept' the terms of the Approval, but cannot change the details of the quote.  When this Broker go in I display (read only) all the details of the quote by setting the session variables from various different files.

The problem is I loose the Session Variables when I get to the Validate All TAB if it was not changed, which means some of the 'Required' Settings does not validate when the Save Button is pressed.

Please help.

Unfortunately

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #2 on: April 12, 2011, 02:27:43 AM »
OK, maybe I cannot explain it well enough.

Please go to
https://grailafrica.dyndns.biz:47245.

I have hardcoded user name and password now.  Once logged in click on Quotations and select 'Approved'.  

Select Quote No 37590/1, Insured ACT 1 and press the Activate Quote button.

Notice Section says: 'Houseowners' and under the History tab, Previously insured is selected as 'Yes'.

Under Activation Details tab, press the As Above button, select a Policy Inception Date and just select Frequency as 'Annual'.

When you press Save, Section changes to '--Please Select--', previously insured changes to 'No', both these settings are the default for Insert.

Now I can probably do a routine and set these Session values again, but I cannot imagine this is the way the templates are suposed to work.

Please!!!!!
« Last Edit: April 12, 2011, 02:33:31 AM by charl99 »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #3 on: April 12, 2011, 06:59:23 AM »
>> I tested a bit around this and it seems only values that you change filters through to the Validate All Routine.

If the field is "read only" then it is not copied from the "Value" to the "Variable" in the CompleteForm routine. ie Read-Only means that the value, whatever it is, is ignored. (Remember the browser is considered to be "untrustworthy").
I'm not sure how this affects your logic.

I've primed both memory, and file fields using the "priming" tab (are you doing this or priming in hand-code?)

Also have you updated your build from 5.15 yet?

cheers
Bruce




charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #4 on: April 13, 2011, 04:56:43 AM »
Hi Bruce,

I am on 5.20 now.

>> If the field is "read only" then it is not copied from the "Value" to the "Variable" in the CompleteForm routine

Ah, that explains it perfectly. 

>> I've primed both memory, and file fields using the "priming" tab (are you doing this or priming in hand-code?)

On Insert I use the Priming Tab with a little bit of hand code after that, and in this handcode I prime both as well.

On Update I only use handcode in the embed point just below the embed point where the priming would take place, as most of the 'memory' fields is in related files, Yes/No questions are stored in strings (eg 0100010100 would be yes,no,yes,yes,no), etc.  and I set only the "Values" and now I know why it does not work.

>> I'm not sure how this affects your logic.

One example would be when a 'Yes' turns to a 'No' the Required logic in the template 'breaks'.  And the information in these 'memory' fields displayed on the screen changes.

I now know what to do, but it is quite cumbersome, and almost all the stuff we do works like this and we have a lot more stuff to do.  (All those licenses we bought was that once I have laid the foundations, the rules, etc the other guys can start to help.)

What is the chances of you including a routine that simply copy all 'Values' to 'Variables', ie all the variables declared as local data?  After setting all the values, I can simply say do SessionValuetoVariable or something like that.

or probably much better, maybe p_web.SetSessionAndVariableValue  (p_web.SSAVV)?

Thanks man, you are the Boss.

Cheers
Charl




Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #5 on: April 13, 2011, 08:52:42 PM »
There's a routine generated in the form procedure called "RestoreMem".
This does the following code on each non-file* field on the form.

  if p_web.IfExistsValue('Mem:Something')
    Mem:Something = p_web.GetValue('Mem:Something')
    p_web.SetSessionValue('Mem:Something',Mem:Something)
  End

* non-file fields are the fields on the form that aren't part of the "form table".
ie it's for memory fields, fields from other tables, and so on.

So I think if you call do RestoreMem you'll get what you want - but check your generated code to be sure.

Cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #6 on: April 14, 2011, 05:28:23 AM »
Hi Bruce,

What I were doing in the PreUpdate Routine (cq:Section being a ‘non-file’ field and QPSE:Section primed from a different table than the Form Table):

  p_web.SetSessionValue('cq:Section’,QPSE:Section)

My understanding was that I should do the following (where cq:Section is but one of a lot of Read-Only’s):

  cq:Section = QPSE:Section
  p_web.SetSessionValue('cq:Section’,cq:Section)

which I tried but this does not work.

In the RestoreMem Routine it does the following:

  if p_web.IfExistsValue('cq:Section')
    cq:Section = p_web.GetValue('cq:Section')
    p_web.SetSessionValue('cq:Section',cq:Section)
  End

Which also does not work, but I was looking for that middle part when I suggested something like p_web.SSAVV.

The ONLY way it seems I can get it to work is to set reset cq:Section and the other fields in the XXXXXXXX below.

ValidateRecord  Routine
  ! Start of "On Insert & Update : Form ends : before disk write"
  ! [Priority 5000]

XXXXXXXXXXXXXX  Repeat the PreUpdate Code Here again for all the Read-Only’s.
 
  ! End of "On Insert & Update : Form ends : before disk write"

It appears that the Variables of the Read-Only Stuff still disappears somewhere.  Is there any solution to this?

By the way, I am on 5.22 now, but I can assure you this was not the case in 5.06.  This problem only manifested when I jumped to 5.15.

Thanks
Charl

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #7 on: April 14, 2011, 06:51:59 AM »
Hallo Charl,


Does make any difference if you check p_web.gsv('SectionCode')  at 1Start or 2End of ValidateAll embed? Try 2End embed.

Regards,
Robert

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #8 on: April 14, 2011, 07:48:28 AM »
I can check the Session Value in the 1Start Embed, it's lost in 2End.

ie think this line is the offending code but I don't know:

  ! End of "On Insert & Update : Form ends : before disk write"
  p_web.DeleteSessionValue('WUpdateQuotes_ChainTo')

I wrote some code to check for update or insert where I ignore a lot of things when update to get around that, which would not have been necessary if I had the Session Values in 2End.  I create and update several related files so I want to make sure all validation is OK before I do this, hence 2End.

I initially picked the problem (for me anyway) up with the Session Values that gone missing, on the Read-Only fields, but now see it is actually the 'Variable' that are not there either upon Validation.  As I said, this part used or at least appeared to work in 5.06. 

Ideally, what I set as a Value (and Variable and hopefully there is an easy way to just copy one to the other after it is setup), regardless of the Read-Only attributes, etc, I would like to carry that which was not changed through to 2End. (Otherwise I have to set it again...)

Thanks anyway, maybe this clarifies things a bit.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #9 on: April 14, 2011, 09:00:39 PM »
I've read this 5 or 6 times now Charl, and I'm still not 100% sure I understand exactly what you're doing.

I think the fastest way to get to a resolution here is if you tweak one of the examples - example 1 will do - to show what you're doing - and hopefully exhibit the problem you're having. Post that here and I can check it out.

cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #10 on: April 15, 2011, 05:56:32 AM »
Sorry, my fault entirely, should have done it in the 1st place but I think I was myself not sure what was going on   ???.

When you compile and run the example, click on the record that says 'Yes', select 'Yes' on proceed and press the Save button without filling in the extra fields.

Notice that the value of 'Is it Required' change to 'No' and that the 'Reason' disappears.

(And although none of the underlying data has changed everybody think the App is screwed.)

Thanks
Charl

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #11 on: April 15, 2011, 06:09:43 AM »
thanks - I'll check it out.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #12 on: April 15, 2011, 10:21:17 PM »
fixed in 5.23.

Thanks for the example - helped a lot.

cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: p_web.gsv() on Update Form does not work? (with EXAMPLE now)
« Reply #13 on: April 16, 2011, 02:40:25 PM »
Thanks.

A very lot.  I promise to make examples in future.

Before I do that, one last thing I picked up, if you have a Form with a Browse and you ' View' the Form, you cannot change any fields on the form.  Until you press on Anything on the Browse.  When you return from the Browse you can pretty mich do anything.

Cheers
Charl