NetTalk Central

Author Topic: Updating other fields on a form based on values in a field  (Read 2568 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Updating other fields on a form based on values in a field
« on: February 25, 2010, 01:34:10 AM »
I would like to update other fields on a form based on a value entered in a field.
I have a field WEBPOL:InsuredValue in which I enter a value. [Image1.png]
On the Client Side Tab I tick the Send New value to server
In the server Code Button
I embed DO CalculatePremium !server side code
In ProcedureRoutines I have this code
CalculatePremium ROUTINE
    IF WEBPOL:InsuredValue
        WEBOPT:InsuredTo = WEBPOL:InsuredValue
        ACCESS:WebOption.Open()
        ACCESS:WebOption.Usefile()
        SET(WEBOPT:SK_ToValue,WEBOPT:SK_ToValue)
        NEXT(WebOption)
        IF ERRORCODE()
            p_web.SetSessionValue('WEBPOL:GrossPremium',0)
        ELSE !Found record
            WEBPOL:GrossPremium = WEBOPT:BasePremium
            p_web.setSessionValue('WEBPOL:GrossPremium',WEBPOL:GrossPremium)
        END
        MESSAGE('WEBPOL:GrossPremium ' & WEBPOL:GrossPremium & ' WEBOPT:BasePremium ' & WEBOPT:BasePremium)
        ACCESS:WebOption.Close()
    END
Exit
The value of WEBPOL:GrossPremium is the same as the value of WEBOPT:BasePremium [Image2.png]
The field WEBPOL:GrossPremium is set as display on the tab but no value is displayed.
I have other fields which will also update in this procedure but I am sure the same principle will apply to them
P.S. The message command will be replaced by CapeSoftMessageBox before production.

Any help appreciated.

[attachment deleted by admin]
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Updating other fields on a form based on values in a field
« Reply #1 on: February 25, 2010, 03:01:35 AM »
Are you refreshing the WEBPOL:GrossPremium and other fields on the Client side Tab?

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Updating other fields on a form based on values in a field
« Reply #2 on: February 25, 2010, 03:39:46 AM »
I found that although the values didn't appear after entereing the InsuredValue they were there if I went back into the record.
Solution was to RESET the fields using the reset browse on the client side tab of POLWEB:InsuredValue
Thanks Kevin
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Updating other fields on a form based on values in a field
« Reply #3 on: February 25, 2010, 09:22:49 PM »
All working great except this.
Problem with byte value set in dictionary as must be true or false
On the Client Side Tab I tick the Send New value to server
In the server Code Button
I embed DO CalculatePremium !server side code
In ProcedureRoutines I have this code
CalculatePremium ROUTINE
 IF  WEBPOL:Simsure <> 0
    WEBPOL:SimsureFee = WEBOPT:Simsure
    p_web.setSessionValue('WEBPOL:SimsureFee',WEBPOL:SimsureFee)
 ELSE
    WEBPOL:SimsureFee = 0
    p_web.SetSessionValue('WEBPOL:SimsureFee',0)
 END
Exit
WEBPOL:Simsure is a byte
I populate the field on the form as a checkbox.
The box is already checked at the point that the above code fires but the value of WEBPOL:Simsure is 0. If I look at the record in the database the value is 1.
Is there anything special about handling or accessing Byte fields?

Any help appreciated.
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: 11193
    • View Profile
Re: Updating other fields on a form based on values in a field
« Reply #4 on: February 25, 2010, 09:53:27 PM »
Hi Terry,

depending on where this is called from, WEBPOL:Simsure may not be set.
use p_web.GSV('WEBPOL:Simsure') instead.

cheers
Bruce