This topic is locked
[SOLVED]

 Pre Populate Child Records

9/11/2013 1:32:42 PM
PHPRunner General questions
P
p1nr author

I have a transaction system which populates the details of each transaction in one table and then populates each individual item within that transaction in another table.

I do this by linking the two tables and enabling the add page option on the relationship/child records option located in the tables tab of PHPrunner.
I was recently asked to set up a few fixed transactions meaning that users will be able to select an option on a drop down field, then have relevant items automatically populate in an 'add new record'. Basically, there will be 3 transaction types now: Custom; Set 1; Set 2. Custom will have nothing pre populate and will just be left blank. Set 1 and 2 however, should pre populate the new transaction with items that I assign to them.
So my question is: how do I pre-populate child details on an add new record based off of a drop down menu? Please let me know if this makes sense.

Sergey Kornilov admin 9/11/2013

You can use BeforeAdd or AfterAdd of the master table for this purpose.
Sample code:

if ($values["DropdownField"]=='Set 1') {

// insert some records into child table

} else if ($values["DropdownField"]=='Set 2') {

// insert some other records into child table

}


Sample code for adding records to child table:

http://xlinesoft.com/phprunner/docs/add.htm

P
p1nr author 9/13/2013

Thanks, but I was looking for more of an onload function. I would like the details to populate based off of a selected drop down, then the user can add/remove details accordingly. Would the the DAL feature allow for this as well?

Sergey Kornilov admin 9/13/2013

If you want to populate child grid right on the Add page it's also possible but it's more complicated. There is no API to help you with this and there is no sample code. You will have to hire someone familiar with Javascript in order to implement this functionality.

P
p1nr author 9/16/2013

I see.. is this something that will come up with future releases?



If you want to populate child grid right on the Add page it's also possible but it's more complicated. There is no API to help you with this and there is no sample code. You will have to hire someone familiar with Javascript in order to implement this functionality.

Sergey Kornilov admin 9/16/2013

Unlikely, this is sort of functionality will still require coding skills even if some sort of API is provided.