This topic is locked
[SOLVED]

 Autofill not working properly in v10.3

2/19/2020 7:30:49 AM
PHPRunner General questions
S
Smithy author

Hello everyone,
I hoping you can assist. I have setup a couple of dependent cascading lookup wizard fields:
WorkOrder -> autofill-part number <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=27129&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

work_order_seq -> (dependent on work_order) autofill - operation code <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=27129&image=2&table=forumtopics' class='bbc_emoticon' alt=':(' />
As far as I can see everything works as expected, except the autofill on the second lookup wizard returns a random value that is not associated with either the work order or the work_order_seq.
On the second lookup wizard I can display the "custom expression" in the 'Display As' field - this work perfectly everytime.

Then I want to autofill the operation code which relates to the work_order_seq lookup wizard, but autofill returns a random value from the database. I tried the WHERE filter box on the lookup wizard but this broke the query - but what it did show was an error message from the database which showed that the query being generated by the lookup wizard was exactly correct.
I really don't understand why it is returning a wrong value, when the value I am after is part of the custom expression, which is correct every soingle time.
I can upload my project to the demo account, but it has a lot of tables. Will it still work without uploading the tables ?
This has driven me mad all day and I am becoming quite desperate to get it fixed.....
Thanks in advance for any help anyone can suggest.
Best regards,

Craig

Sergey Kornilov admin 2/19/2020

Autofill works based on a single lookup wizard. I guess you expect autofill to work based on two lookup wizards selection and this is why you are not getting the results you expect.
The solution in your case is to implement a Field Event that will pull the data from the lookup wizard based on two previous lookup wizards selection.

S
Smithy author 2/19/2020



Autofill works based on a single lookup wizard. I guess you expect autofill to work based on two lookup wizards selection and this is why you are not getting the results you expect.
The solution in your case is to implement a Field Event that will pull the data from the lookup wizard based on two previous lookup wizards selection.


Thank you Sergey.
I hope the images work in this post - I have linked them from imgur and can't see them in the preview.....
I thought the same thing. So I deleted my project and started again. At the risk of exposing my ignorance here, I have detailed the process I have used below, in the hope that you can assist. I have tried field events also, without success. I expect I will ned to ask a few questions on these in a short while. But to state my procedure :


1: I choose the work order from a list. This is a lookup wizard, and is not dependent on any other lookups. This lookup wizard has three fields that Autofill. (marked number 2)

  • wo_bom_id
  • wo_route_id
  • itemcode


This works fine every time.
3 - continue to next step.


4 - This is another lookup wizard to get the work order sequence. It is dependent on the work order number previously chosen at step 1. The work order number limits the sequence numbers that can be chosen at step 5. I have setup this lookup wizard to display a custom expression that shows the sequence number, the Op Code and the work centre. This display query is always correct, and has never had any errors. I want to use Autofill on this lookup wizard to fill in the field Op Code. In this case I want it to Autofill the Op Code with "PACK".


6 - The autofill is returning a random string that is unrelated to the work order or the sequence number. This is my issue. I don't understand how the lookup wizard custom expression display can be correct every time, but the Autofill is not using the same field.
For reference I have included a snapshot of the data from the actual data table. (step 7)


I have also included a screen shot of the lookup wizard for the work order sequence. I do not believe I am trying to carryout two simultaneous dependencies. The "display as" part is working as expected, but the Autofill isn't.


Can I please ask for some guidance on the field events, as I don't know how to carry out an sql enquiry to retrieve the data. A website or anything like that woud be greatly appreciated.
Thanks for your help.
Craig

Sergey Kornilov admin 2/20/2020

Images cannot be seen but there are a few issues here.

  1. Custom expression has nothing to do with Autofill. Custom expression just changes the display of the selected record. The issue is not with the display but with the fact incorrect record is selected.
  2. Your second autofill is based on two lookup wizards. The first one filters the data and the second one allows to select a record from the filtered list. Autofill doesn't know anything about the first dropdown, it filles data solely based on the link field value. It picks the first record with the matching link field value and it looks random to you while in fact it is not.
    Possible solutions.
  3. Make sure that link field of the second lookup wizard contains unique values.
  4. Or use field events to fill fields automatically based on two lookup wizard selections.
    Here is the article on field events:

    https://xlinesoft.com/phprunner/docs/field_events.htm

    It explains how to pass data between events, how to execute SQL query and pass data back etc.

Sergey Kornilov admin 2/20/2020

And also here is the article that explains how to implement Autofill based on two other fields selection:

https://xlinesoft.com/blog/2020/02/20/autofill-based-on-two-fields-selection/

S
Smithy author 2/20/2020



And also here is the article that explains how to implement Autofill based on two other fields selection:

https://xlinesoft.com/blog/2020/02/20/autofill-based-on-two-fields-selection/


Thank you very much Sergey.
I have stopped using the dependencies and autofill and have got the field events to work.
Here are the three sections of code so that other may wish to use if needed.
The field event is attached to the work_order_sequence field as a "change" event:

function OnClient Before(params,ctrl,pageObj,ajax)

{

var ctrlworkorder = ctrl.getPeer('work_order');

params["worder_in"] = ctrlworkorder.getValue();
var ctrlwoseq = ctrl.getPeer('wo_seq');
if (ctrlwoseq.getValue()== '')

params["woseq_in"] = 0;

else

params["woseq_in"] = ctrlwoseq.getValue();

}



Note: I had to put in a check for the value of the work order sequence. For some reason the change event on wo_seq_no would fire after updating the work_order lookup, even though they are not connected, and would cause a red "server error" message to appear at the top of the screen. This was because the work_order_seq being passed to the mysql server had a where clause that ended in "and wo_seq_no =)" . The work_order_sequence was blank and this caused an error. By changing it to 0 it lets the field event fire but nothing is returned from the server.

function OnServer($params, $result)

{

$result["wo_op_code"] = DBLookup("SELECT wor_op_code FROM wo_route_data WHERE (work_order=" . $params['worder_in'] . " AND wor_seq_no = " . $params['woseq_in'] . ")");

}




function OnClient After(result,ctrl,pageObj,ajax)

{

var ctrlwoopcode = ctrl.getPeer('op_code');

ctrlwoopcode.setValue(result["wo_op_code"]);

}


This was adapted from the "Autofill based on two fields selection" article you referred to in your last post.
Thank you so much, I got it working and can see many more uses for it. I can't tell you how good this is going to make my new and upcoming projects.
Best regards,
Craig