This topic is locked

problem gertting proxy value

9/5/2023 11:28:37 AM
PHPRunner Tips and Tricks
M
Mauipm author

Hi all,
i am going slightly mad with this problem:
I have an ADD page with some fields. For one of them (id_attivita) I must test if it has been used in other record (it is possible)
In "Before record added" event (PHP) I do the control getting an answer ("YES"/"NO") and I put it into a "proxy value":
For example:
$yesno="NO"
$pageObject->setProxyValue("duplicated",$yesno );
in JavaScript Onload Event

  • I get the proxy value ("YES or "NO"):

is_duplicated=proxy['duplicated'];

  • if (is_duplicated=="YES") show an alert box with a message like "the value has been already used, do you confirm that?" and if confirmed, it save the record, otherwise no.

The problem is that I can't get the proxy "duplicated" value; I always get an empty string (or a NULL value)
If I force manually the value of is_duplicated, everithing works fine
Many thanks for your suggestions
Mauro

Admin 9/5/2023

You need to read PHPRunner's manual related to setProxyValue() function that explains what event you need to use this function in:
https://xlinesoft.com/phprunner/docs/setproxyvalue.htm

M
Mauipm author 9/5/2023

HI,
I used all the examples from Help and from other posts:

  • alert(proxy['duplicato']); to test


  • window.proxy = proxy;


  • alert(window.proxy['duplicato']);


  • window.proxy['duplicato'];



I tried every "combination" without results

Admin 9/5/2023

You are using a wrong event. The manual of setProxyValue() function says that you need to use BeforeDisplay event. You are saying that you are using Before record added which, of course, will not work. This is the source of your problems.
Make sure you read the manual and follow it.

M
Mauipm author 9/6/2023

Many thanks,
really I read "BeforeDisplay event" only in Example 2 of "Advanced topics > Programming topics > Page class > Methods > setProxyValue"; I didn't find the info that i "must" be in Before Display", to set proxy value, but good to know)
so I must find another way for saving procedure (i.e. custom button) to be able to test before save
Mauro

Admin 9/6/2023

The info is right there.
img alt

M
Mauipm author 9/7/2023

Hi,
the problem is that sometimes I get error searching the manual on-line, so I'm used to use the HELP in local. Even if using 10.91, the local manual is updated to 10.8, and says
"Sets the variable to the given value. Use the setProxyValue() method to pass PHP values to JavaScript: you assign value to a variable in PHP and then use it in JavaScript.
This method is available on all pages."
Thanks again
Mauro