Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Transaction Patterns » PopUpForm (Retrieving additional field values)
PopUpForm [message #4241] Fri, 06 June 2014 11:09 Go to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Hi Tony,
I have created a popUp Task which shows me the entries of a lookup table and inserts the PKey-Fields (user_id, user_seq_no) in the child table.
Now I want to get additional field values (user_name, user_firstname) from the parent table for also inserting in the child table. The $select_array contains only the pkey values.
How can I get these additional values best?

Best regards,

Juergen
Re: PopUpForm [message #4242 is a reply to message #4241] Fri, 06 June 2014 11:22 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
By default the popup form will only return the primary key of the selected entry. There ate two ways to obtain other (non-key) values:
(1) Use the _cm_getPkeyNames() method in the popup form to add extra field names to the list of primary key fields.
(2) After returning to the form which called the popup you may insert code to read the record with that primary key. This will give you access to all the data on the selected record. You can put code in the _cm_popupReturn() method or the _cm_post_popupReturn() method.


Re: PopUpForm [message #4245 is a reply to message #4242] Sat, 07 June 2014 07:29 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
I try to get the data by adding these lines of code to my class file:

function _cm_post_popupReturn ($fieldarray, $return_from, $select_array)
{
// get contents of foreign table HTM_DB_KONTAKTE
$dbobject =& RDCsingleton::getInstance('htm_db_kontakte'); // Lookup-Tabelle
$where = "kontakt_name=$select_array['user_id'] AND kontakt_vorname=$select_array['user_seq_no']";
$array = $dbobject->_dml_getData ($where); // PKey-Felder

$fieldarray['kontakt_ma_name'] = $array['kontakt_name'];
$fieldarray['kontakt_ma_vorname'] = $array['kontakt_vorname'];

return $fieldarray;

}

I am not so familiar with PHP and OO Programming although I read a lot but doing it is something different. That's why I am absolutely not sure if this is the right way.
Can you give me some advice?
Re: PopUpForm [message #4246 is a reply to message #4245] Sat, 07 June 2014 08:18 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
Do not use the $dbobject_dml_getData() method , use $dbobject->getData() instead.

When you construct the WHERE string you must remember to enclose non-numeric values with single quotes.

The result returned by getData() is a 2-dimensional array which is keyed by row numnber, with the value being an associative array of name=value pairs. Your code should therefore look like this:
$dbobject =& RDCsingleton::getInstance('htm_db_kontakte');
$where = "kontakt_name='{$select_array['user_id']}' AND kontakt_vorname='{$select_array['user_seq_no']}'"; 
$data = $dbobject->getData ($where);
if (!empty($data) {
    $data = $data[0];
    $fieldarray['kontakt_ma_name'] = $data['kontakt_name'];
    $fieldarray['kontakt_ma_vorname'] = $data['kontakt_vorname'];
} // if


Re: PopUpForm [message #4247 is a reply to message #4246] Sat, 07 June 2014 13:13 Go to previous message
htManager is currently offline  htManager
Messages: 433
Registered: May 2014
Senior Member
Thank you very much. It works perfectly!
Previous Topic: Virtual Private Database and List 2 pattern
Next Topic: Dropdown list
Goto Forum:
  


Current Time: Mon Nov 18 02:35:17 EST 2024

Total time taken to generate the page: 0.01131 seconds