NetTalk Central

Author Topic: IfExistsSessionValue  (Read 5445 times)

alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
IfExistsSessionValue
« on: August 09, 2013, 02:46:35 AM »
I have a form using two columns (act:attorneyEmail and act:contactEmail) from a table names Accounts.

As the user accepts act:attorneyEmail, I want to default contactEmail to the same value, if contactEmail doesn't already have a value.

I found that p_web.SetSessionValue('act:contactemail',act:attorneyemail) will set the value correctly, but I can't get this to operate conditionally.  Here's what I tried (among many other things):

if p_web.IfExistsSessionValue('act:ContactEmail') = 0
  p_web.SetSessionValue('act:contactemail',act:attorneyemail)
end

In this code, the contactEmail is ALWAYS updated to equal attorneyEmail.  I found IfExistsSessionValue is always returning "1", even when I haven't yet touched contactEmail.

Obviously there's something very basic I don't yet understand.  Help would be appreciated.

Alan
Alan Schoolcraft

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: IfExistsSessionValue
« Reply #1 on: August 09, 2013, 03:09:47 AM »
Hi Alan,

You almost got it  ;)
In your example p_web.IfExistsSessionValue() always returns true simply because the sessionvar exists (it's 'automagically' created as you have that column in your record).

What you're really interested in is the value or content of act:ContactEmail. So something like this should work:

if p_web.gsv('act:contactemail') = ''
   p_web.ssv('act:contactemail',p_web.gsv('act:attorneyemail'))
end

Peter

alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: IfExistsSessionValue
« Reply #2 on: August 09, 2013, 06:58:30 AM »
Thanks Peter,

But......with that change I still bet the same result.  When a value is first entered for attorneyEmail, it is in fact defaulted into and displayed in contactEmail.

But. when I go back and change the value in attorneyEmail, I would expect contactEmail to be unchanged since it now has a value.  Instead, contactEmail continues to be updated to reflect changes in attorneyEmail.

It seems that SSV is not "permanently" changing contactEmail - it's just displaying the value without actually writing it into the sessionqueue.  I remain confused.....

Alan
Alan Schoolcraft

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: IfExistsSessionValue
« Reply #3 on: August 09, 2013, 08:07:34 AM »
_where_ are you embedding this?
Right-click on the procedure, choose "source", and see what routine it's in.
Also - look for any other embed code you might have in the procedure that changes this SessionValue.

Cheers
Bruce

alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: IfExistsSessionValue
« Reply #4 on: August 09, 2013, 08:51:19 AM »
I have Client-side on attorneyEmail set to reset contactEmail.  The embed code is on contactEmail 4 Value Routine.

Alan Schoolcraft

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: IfExistsSessionValue
« Reply #5 on: August 11, 2013, 04:15:43 AM »
I'd move the embed code to the Validate::AttorneyEmail procedure.
That's the code that gets executed when the AttorneyEmail value changes.

cheers
Bruce

alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: IfExistsSessionValue
« Reply #6 on: August 12, 2013, 08:13:08 AM »
problem solved: If I assign the returnvalue for GSV to a string, and then check the string, it works as expected.

This doesn't work: (the value is always copied)
if p_web.GSV('act:conatactemail') = ''
  p_web.SSV('act:contactemail',p_web.GSV('act:attorneyemail'))
end

This works: (the value only copies if act:contactemail = '')
loc:tempstring = p_web.GSV('act:contactemail')
if loc:tempstring = ''
  p_web.SSV('act:contactemail',p_web.GSV('act:attorneyemail'))
end
Alan Schoolcraft

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: IfExistsSessionValue
« Reply #7 on: August 12, 2013, 01:55:21 PM »
Maybe Bruce can explain that!?
But glad you got it working.
Peter

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: IfExistsSessionValue
« Reply #8 on: August 12, 2013, 10:04:55 PM »
that code is the same, so I can't explain the difference. I suspect something else is in play.

cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: IfExistsSessionValue
« Reply #9 on: August 13, 2013, 12:08:27 AM »

This doesn't work: (the value is always copied)
if p_web.GSV('act:conatactemail') = ''

If the above is a direct copy then maybe the spelling of act:contactemail is the problem?
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186