Going crazy, problem with Server Function and List

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
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Going crazy, problem with Server Function and List

Post by atostaine »

I have a Material Design drop down. I call a server function to load a list.

I have 4 fields in the list. The two bolded fields are numeric.

def_list #shipperD2 type(*working) entrys(*max) fields(#SHNAME #ShAcco001 #shAlphaCD #shCntl001)

Here is the call to the server function:
#mLoadShippersInv.execute(#usr #ShipperD2)

Here is the definition of the SF.
srvRoutine mLoadShippersInv Session(*REQUIRED)
field_map for(*input) field(#usr)
list_map for(*output) list(#shipperD2)
...

In the server function, at the end of the mLoadShippersInv , I do this to confirm the list is populated:

selectList #shipperD2
#SYS_APPLN.TraceMessageText(('Select shCntl001 &1 shAcco001 &2 shName &3').substitute(#shCntl001.asString #shAcco001.asString #shname))
endSelect

Here are the first two records of the log file from green screen:

510 Select shCntl001 0 shAcco001 1 shName XYZ Company
510 Select shCntl001 50113 shAcco001 50113 shName Arts Company

Here I log to console in the RP for the Drop Down
evtRoutine (#mLoadShippersInv.Completed)
selectlist #shipperD2
#dropDown.Items.Add( #shAcco001.asString #shName)
#MySystemManager.LogtoConsole Text(('ADD to dropdown &1-&2-&3-&4').Substitute( #SHNAME #ShAcco001.asstring #shAlphaCD #shCntl001.asString))
endSelect

My console shows the names (that I obscured for some reason), but no numbers
console.png
console.png (1.64 KiB) Viewed 17492 times
I have spent hours on this. I've tried changing the name of the list, removing the #dropdown.items.add and just read through the list. Nothing works.

I'll take any suggestions :oops:
Art Tostaine
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Going crazy, problem with Server Function and List

Post by dannyoorburg »

Hi Art,

You're probably misinterpreting the Add method.

https://docs.lansa.com/14/en/lansa016/p ... ms_add.htm

Material Design dropdowns can only ever show one string value per entry...

The method has 2 parameters because value and caption don't necessarily always match.

Cheers,
Danny
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Going crazy, problem with Server Function and List

Post by atostaine »

I want the value to be the shipper number, and the caption to be the name. Isn’t that what I’m doing?

I referenced this post

viewtopic.php?f=3&t=1832&p=4539&hilit=Combo+box#p4540
Art Tostaine
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Going crazy, problem with Server Function and List

Post by dannyoorburg »

Hi Art,

sorry, catching up.

Is there anything else special about those 3 fields (#ShAcco001 #shAlphaCD #shCntl001)?

Are they components?

Are they long names with a different identifier?

Does it do the same if you comment out the Add but leave in the Trace?

As a last resort, can you see the request coming back with the LIST fully populated in the JSON payload? (Press F12 in chrome, look at the network traffic and click on the request to the server routine, there will be response JSON you can try to find the list in. )

Let me know,
Danny
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Going crazy, problem with Server Function and List

Post by atostaine »

The fields are just imported from an IBM i other file. I don’t think they are components, I will confirm that.

I had already tried commenting out the add and that did not solve the problem.

I’ve tried to use the console to check Json before but never
Got it figured out. I will try that tomorrow .

Thank you
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Going crazy, problem with Server Function and List

Post by atostaine »

F12 shows the data going to the browser correctly .

Here is a snippet:

"entries":[["XYZ Company,1,"",0],["Arts Company",50113,"",50113]
Art Tostaine
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Going crazy, problem with Server Function and List

Post by dannyoorburg »

Hi Art,

If you're still looking, what are the field names in the JSON, I think it's above [entries] in a header variable, I might be wrong....

And how do they compare to the field names in the generated JavaScript for the call to the Server?

Danny
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Going crazy, problem with Server Function and List

Post by atostaine »

All of the field values were mapped in the JSON correctly.

I worked with Paul Odle, and here is what the problem is. The list has the same field names as the define_map's for the MthRoutine.

MthRoutine mLoad
define_map for(*input) class(#shAcco001) Mandatory(0)
define_map for(*input) class(#shCntl001) Mandatory(0)

def_list #shipperD2 type(*working) entrys(*max) fields(#SHNAME #ShAcco001 #shAlphaCD #shCntl001)

During the selectlist the value is always the one from the define_map, not the list.

Adding a name to the define_map (which I ALWAYS do, except here for some reason) solved the problem.

define_map for(*input) class(#shAcco001) Mandatory(0) name(#pShAcco001)
define_map for(*input) class(#shCntl001) Mandatory(0) name(#pShCntl001)

I can provide any other info needed. I think the compiler should tell me that this is bad or its a defect?
Art Tostaine
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Going crazy, problem with Server Function and List

Post by dannyoorburg »

Hi,

Well done to both you. That wouldn't have been obvious.

I guess it's technically correct for a local parameter to obscure a global field.

But not very helpful indeed.

Did either of you log it as a defect, do you know?

Cheers,
Danny
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Going crazy, problem with Server Function and List

Post by atostaine »

I’ll let Paul know . Thanks for the help.

Art
Art Tostaine
Post Reply