Page 1 of 1
Passing a List to Web Event Function
Posted: Wed Sep 21, 2022 6:47 am
by caseywhite
Has anyone had any luck passing a list to webevent function. I have tried posting values to be in the same format as what would be posted once a function has been displayed but it would appear this doesn't work, most likely because LANSA hasn't established what list names exist yet.
_PROCESS: TESTING
_FUNCTION: TEST01
_PARTITION: DEV
AFF_TXT10A: C
AFF_TXT10B: D
_BLNAME: TEST
__SA_TXT010 -0001 D: E
__SA_TXT010 -0002 D: F
_BLEND: TEST
The only other option I can think of is to limit the number or rows in the list that can be passed and have a working field defined that represents each possible row and column in the list. So in my example I would have ASA_TXT10A and ASA_TXT10B that would be posted instead. The function would create a list row for each field that is not blank.
Am I missing something that would allow me to just pass the list without having lots of work fields?
Re: Passing a List to Web Event Function
Posted: Thu Sep 22, 2022 2:17 am
by Dino
Hi Casey
Are you trying to pass a list to a webevent function from a non lansa html page?
because I dont see any problem passing a list from a webevent function to another.
what version of LANSA are you using?
kind regards
Re: Passing a List to Web Event Function
Posted: Thu Sep 22, 2022 2:41 am
by caseywhite
Dino. I want to pass it from an external non LANSA page to a LANSA function. From what I can tell this doens't work because unless you have served the LANSA page first, posting anything browselist related to the function won't work.
Re: Passing a List to Web Event Function
Posted: Thu Sep 22, 2022 2:52 am
by Dino
Maybe time to bring the gap and use json in a webevent (if you are in V15 or maybe even V14)... like if your function is like this:
Code: Select all
Function Options(*DIRECT *WEBEVENT)
Def_List Name(#LIST_A) Fields(#EMPNO #SURNAME)
Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader) Reference(*DEFERRED)
Define_Com Class(#XPRIM_ErrorInfo) Name(#ErrorObject) Reference(*DEFERRED)
Define_Com Class(#PRIM_BOLN) Name(#Found)
#Reader.SetSourceString String(#STD_STRNG) Errorinfo(#ErrorObject)
#Reader.BeginArrayWithPath Path('/EMPLOYEES') Found(#Found)
Begin_Loop Using(#STD_NUM) To(#Reader.GetChildCount)
#Reader.BeginObjectAtIndex Index(#STD_NUM) Found(#Found)
If (#Found)
#EMPNO := #Reader.ReadStringWithName( 'NAME' ).AsNativeString
#SURNAME := #Reader.ReadStringWithName( 'EMAIL' ).AsNativeString
#Reader.EndObject
Endif
Add_Entry To_List(#LIST_A)
End_Loop
#Reader.EndArray
Display Browselist(#LIST_A) Exit_Key(*NO) Menu_Key(*NO) User_Keys((10 NEXT))
* This function receives a #STD_STRNG by funcparms like
* http://localhost:8080/CGI-BIN/LANSAWEB?PROCFUN+TES921PR+TES921B+RHO+ENG+FUNCPARMS+STD_STRNG(A5120):{"employees":[{"name":"Ram","email":"[email protected]","age":23},{"name":"Bob","email":"[email protected]","age":41}]}
and to call this function your url will be like:
ht tp://localh ost:8080/CGI-BIN/LANSAWEB?PROCFUN+TES921PR+TES921B+RHO+ENG+FUNCPARMS+STD_STRNG(A5120):{"employees":[{"name":"Ram","email":"
[email protected]","age":23},{"name":"Bob","email":"
[email protected]","age":41}]}
and the result will be like:

- webeventandjson.png (84.78 KiB) Viewed 14967 times
maybe I just seeing too much json this days....
be aware of the limits... I dont see a way to make funcparms to accept 65535 characters or similar... it is only 3 digits for length... so 512.
Re: Passing a List to Web Event Function
Posted: Thu Sep 22, 2022 8:49 am
by caseywhite
Thanks Dino. Definitely good food for thought.