TOPIC: ChooseListControl,sending arguments to Rules
#1683
ChooseListControl,sending arguments to Rules 8 Months, 3 Weeks ago
I have the next script and run sucessfull:

Field_tipotelefono //item



Field_number

{

Prompt: 'Tipo de Tel.'

Control: (ChooseList listField: 'gettipotelefono' listSeparator : ' - ')

}





Rule_gettipotelefono //item



function ()

{

//Alert('Dentro de la funcion', .Map!, flags: MB.ICONQUESTION)

return QueryAll('trelleno where tabla_name = "trtipotelefono" join trellenodet').Map!({|x| String(x.codigo) $ " - " $ x.descripcion})



}



My question is: I can send arguments at the function inside the rule?

For example:

Field_tipotelefono //item

Field_number

{
Prompt: 'Tipo de Tel.'
Control: (ChooseList listField: 'gettipotelefono("trtipotelefono")' listSeparator : ' - ')

}

Rule_gettipotelefono //item

function (as_tabla)

{

//Alert('Dentro de la funcion', .Map!, flags: MB.ICONQUESTION)

return QueryAll('trelleno where tabla_name = '$as_tabla$' join trellenodet').Map!({|x| String(x.codigo) $ " - " $ x.descripcion})

}

I was trying, I didn't get an error, but doesn't function. Is possible to debug step by step in Suneido?, to watch variables, objects in memory, arguments, etc. Thanks a lot.
 
 
#1687
Re:ChooseListControl,sending arguments to Rules 8 Months, 3 Weeks ago
Rules do not take arguments, but they are executed as if they were methods of the record, so they can access other members with .field

So if you have a record r = [a: 12, b: 34] and

Rule_c
function () { .a + .b }

then r.c will return 46

RuleTest in stdlib has more examples.
 
 
andrew