custom field value

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
GT73
User
Posts: 415

custom field value

Post by GT73 »

Hi, I'd need inserting a default value in to custom field. I tried with these query but don't works
default value = ("select parametri.ValoreSconto FROM parametri WHERE parametri.idParametro = (SELECT azienda.idParametri FROM azienda)")

I tried so but don't works
Page_load
$sconto = ExecuteScalar("select parametri.ValorePunti from parametri WHERE parametri.idParametro =(SELECT idParametri FROM azienda)");
$this->c_Sconto->CurrentValue = $sconto;


mobhar
User
Posts: 11727

Post by mobhar »

Make sure this part "SELECT idParametri FROM azienda" won't return more than one record. In addition, try to use "Row_Rendered" server event instead.


GT73
User
Posts: 415

Post by GT73 »

field table Azienda
idParametro->FK->parametri(1)

field table parametri
id1 -> ValorePunti (1) ValoreSconto (10)
id2 -> ValorePunti (3) ValoreSconto (40)
id3 -> ValorePunti (5) ValoreSconto (20)
...
custom field table movimenti
c_Sconto = Expression ->(select parametri.ValoreSconto from parametri WHERE parametri.idParametro = (SELECT idParametri FROM azienda)) in list page I see = 10
c_AssegnaPunti = Expression ->(select parametri.ValorePunti from parametri WHERE parametri.idParametro = (SELECT idParametri FROM azienda)) in list page I see = 1

table movimenti
//Row Rendered event
function Row_Rendered() {
// To view properties of field class, use:
//var_dump($this-><FieldName>);
$sconto = ExecuteScalar("select parametri.ValoreSconto from parametri WHERE parametri.idParametro =(SELECT idParametri FROM azienda)");
$punti = ExecuteScalar("select parametri.ValorePunti from parametri WHERE parametri.idParametro =(SELECT idParametri FROM azienda)");
$this->c_Sconto->CurrentValue = $sconto;
$this->c_AssegnaPunti->CurrentValue = $punti;
}

returns only one record. the ValorePunti field is an EditTag-> Select field with 1,2,3,4,5, as values, only one value is selected (1). should return 1 but not work.
returns only one record. the ValoreSconto is an EditTag-> Select field with 0,5,10,15,20,25,30 ... 100 etc. .. only one value is selected (10). should return 10 but does not work.

when I'm in add page I don't see any value


mobhar
User
Posts: 11727

Post by mobhar »

This code:
$this->c_Sconto->CurrentValue = $sconto;
$this->c_AssegnaPunti->CurrentValue = $punti;

change to:
$this->c_Sconto->ViewValue = $sconto;
$this->c_AssegnaPunti->ViewValue = $punti;


GT73
User
Posts: 415

Post by GT73 »

I deleted the expression from the custom fields, it works like this...

function Row_Rendered() {
// To view properties of field class, use:
//var_dump($this-><FieldName>);
$sconto = ExecuteScalar("select parametri.ValoreSconto from parametri WHERE parametri.idParametro =(SELECT idParametri FROM azienda)");
$punti = ExecuteScalar("select parametri.ValorePunti from parametri WHERE parametri.idParametro =(SELECT idParametri FROM azienda)");
$this->c_ValoreSconto->CurrentValue = $sconto;
$this->c_ValorePunti->CurrentValue = $punti;
}

the two custom fields are in lookup table, how can I display the "label" of the original field in "DisplayField # .."?


mobhar
User
Posts: 11727

Post by mobhar »

GT73 wrote:
how can I display the "label" of the original field in "DisplayField # .."?

Just assign the "ViewValue" property of that field like the code I gave you before.


Post Reply