Passing a List to Web Event Function

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Passing a List to Web Event Function

Post 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?
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Passing a List to Web Event Function

Post 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
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Passing a List to Web Event Function

Post 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.
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Passing a List to Web Event Function

Post 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
webeventandjson.png (84.78 KiB) Viewed 14959 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.
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Passing a List to Web Event Function

Post by caseywhite »

Thanks Dino. Definitely good food for thought.
Post Reply