<FORM> <OnLoadForm> multiple parameters

25 views
Skip to first unread message

Andrew Makinson

unread,
Jan 25, 2017, 9:49:11 AM1/25/17
to InterSystems: Zen Community
Using a <FORM>

The OnLoadForm attribute calls a method but doesnt allow definition...

It seems to send pKey and accepts back pValues

Method LoadForm(pKey As %String,
                ByRef pValues As %String) As %Status

Is there any way to send more than just pKey as I need multiple values when loading the form.


Vlado

unread,
Jan 27, 2017, 2:32:15 AM1/27/17
to InterSystems: Zen Community
Hi Andrew,
You can  define pKey as a  string of multiple values with a delimiter:

Set pKey=pKey1_","_pKey2_","....

And after that extract each values:

Method LoadForm(pKey As %String,
                ByRef pValues As %String) As %Status
{
  Set pKey1=$p(pKey,",",1)
  Set pKey2=$p(pKey,",",2)
  .....
  Set cmp = ##class(ZENDemo.Data.Company).%OpenId(pKey1)
  If ($IsObject(cmp)) {
...
  Set emp = ##class(ZENDemo.Data.Employee).%OpenId(pKey2)
  If ($IsObject(emp)) {

**Владо

Andrew Makinson

unread,
Jan 29, 2017, 3:07:28 PM1/29/17
to InterSystems: Zen Community
Hi Vllado,

Thanks for this - but when this LoadForm is called from within a <form> how do I get it to pass the two variables into pKey for example...

<form id="Fields" OnLoadForm="LoadForm">

Vlado

unread,
Jan 30, 2017, 4:27:12 AM1/30/17
to InterSystems: Zen Community
It depends how you call the form.
One way would be to pass the values via url.
-----------------------------------------------------------------------------------------------------
/// This property holds the ID1 passed in by URL (if any).
Property pKey1 As %ZEN.Datatype.string ( ZENURL = "ID1" );

/// This property holds the ID2 passed in by URL (if any).
Property pKey2 As %ZEN.Datatype.string ( ZENURL = "ID2" );
-----------------------------------------------------------------------------------------------------
Now you can use the attribute  "key" with  Zen runtime expression.
(Only if the Form is not connected to a dataController!).
-----------------------------------------------------------------------------------------------------------------------
<form id="FieldsOnLoadForm="LoadForm" key="#(%page.pKey1)#,#(%page.pKey2)#"
-----------------------------------------------------------------------------------------------------------------------

**Владо
Reply all
Reply to author
Forward
0 new messages