Store data not ID in a Dropdown

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
jstrick
Posts: 13
Joined: 2013-03-04 20:55

Store data not ID in a Dropdown

Post by jstrick » 2013-09-08 16:45

The question is how do you tell a drop down to store data not the ID?

Reason when I am sending out emails in the hook folder the array sends the ID column not the real data. Anyone no any code to help with this or am i building the drop downs wrong in the program.

Any help would be appreciated.

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Store data not ID in a Dropdown

Post by benzoD » 2013-09-09 16:53

Have you inserted data into the table yet? I've had no problem using the basic email code in the tutorials (after changing it to my specific info), which is what I assume you've used. From the small amount of information you've provided, it sounds like you've input the field names as the data, changed the code to display the field names as the data, or somehow created a dropdown populated with a table's fields.

More information is required as to your situation, what you've tried, what code you're currently using, etc. For starters, are your dropdowns foreign keys, or simply a list?

jstrick
Posts: 13
Joined: 2013-03-04 20:55

Re: Store data not ID in a Dropdown

Post by jstrick » 2013-09-10 21:20

Ok let me try and explain better.

In the appgini program I select lookup field it give me a code like this in the assigned technician field:

SELECT `technicians`.`id`, IF( CHAR_LENGTH(`membershipusersview1`.`memberID`), CONCAT_WS('', `membershipusersview1`.`memberID`), '') FROM `technicians` LEFT JOIN `membershipusersview` as membershipusersview1 ON `membershipusersview1`.`memberID`=`technicians`.`technicianname` ORDER BY 2

So when it sends out an email it sends out lets say the first technician ID Number. When I look in Phpmyadmin on my server it is stored as 1 not as Tom Thumb are whoever. I am guessing it needs to store the real name to show the data. I use to work with ms access and you had to tell it which column to store. Now it works fine on the form in the web page just not correct in the email.

Code for the email:

$recID=mysql_insert_id();
//sql("insert into membership_userrecords set tableName='workorder', pkValue='$recID', memberID='".getLoggedMemberID()."', dateAdded='".time()."', dateUpdated='".time()."', groupID='".getLoggedGroupID()."'", $eo);

// to compose a message containing the submitted data,
// we need to iterate through the $data array
foreach($data as $field => $value){
$messageData .= "$field: $value \n";
}

@mail(
// mail recipient
"Allwhoneed.com",

// subject
"{$data['propertyname']} has a new work order that needs your attention",

// message
"PLEASE DO NOT REPLY TO THIS MESSAGE\n\n".
"To view it, please go to: http: kigoma.hobby-site.com/workorder101/workorder_view.php?SelectedID=$recID \n".
"The following new record was submitted by {$memberInfo['username']}: \n".
$messageData,


// sender address
"From: Somthing.com"
);
return (get_magic_quotes_gpc() ? stripslashes($recID) : $recID);
}

The above was tweaked from appi.
As you can see i am sure
Hope this makes since.

And thanks for the help

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Store data not ID in a Dropdown

Post by benzoD » 2013-11-20 19:23

Sorry, I just saw this today. I now understand your situation and am also wrestling with this very problem: http://forums.appgini.com/phpbb/viewtopic.php?f=2&t=846 . It's converting non-integer values into integers but they're not converted back when other lookups use the value.

I also have had no response to my forum post. It's caused me to redo a large section of the app and really limits the value of at least one part of the app. We were going to change a policy when this is rolled out based on the new values created by the inventory system I've use AG for, but this issue has thrown that into limbo.

jstrick
Posts: 13
Joined: 2013-03-04 20:55

Re: Store data not ID in a Dropdown

Post by jstrick » 2013-11-21 23:14

The only sort of answer I have found is to use let's say the property name as the id. But I wanted to pull an email field I had in the table but it come across as the id not the actual field data. So still looking for an answer if anyone out their has one. Maybe we aren't building the table properly. Are maybe the query we build for drop downs is build incorrect. I just don't know. In msacces you have to tell it to save the info in the second column. Can't seem to find anything like that in php/mysql.
If ya got anything let me know.

User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

Re: Store data not ID in a Dropdown

Post by toconnell » 2014-04-14 18:41

I got my email code to work and display all the fields.. here is my code for you to use..

The issue for me was I was putting it in after insert... wrong place.. that is for a new record getting inserted.. when I put it into "after update", when the record was changed my email sent.

You will need to change the table names, domain names and email addresses below to yours.

You can put the code in both places if you want.. should be put in the YourTableName.php folder inside the hooks folder.. under the function after_update or after_insert or both.. After insert happens after a new record is added to the table. after_update happens after a record is updated in the table. I hope this helps you all.

here goes..

Code: Select all

function YourTableName_after_update($data, $memberInfo, &$args){

foreach($data as $field => $value){
$messageData .= "$field: $value \n";
}
$recID=mysql_insert_id();
sql("insert into membership_userrecords set tableName='YourTableName' , pkValue='#recID', 
memberID=' ".getLoggedMemberID()."', dateAdded=' ".time()."', dateUpdated='".time()."',
groupID= ".getLoggedGroupID().".", $eo);
 
@mail(
// mail recipient
"[email protected], [email protected]",
 
// subject
"A Record in the Driver Compliance table of the database was changed - notification - Driver RECORD NUMBER-{$data['Record_Id']}",
 
// message
      "The above record {$data['Record_Id']} was just modified by:{$memberInfo['username']} The record was updated on and by:{$data['LastUpdatedby']} \n To view the record please go to \n http://YourDomainName.com/YourAppGiniFileFolder/YourTableName_view.php?SelectedID=".$data['selectedID']."  Newly entered data shows as actual table values below:,
	 {$messageData} \n.  The user that changed this record did so from IP Address: {$memberInfo['IP']}  \n\n", 
	  
 
// sender address
"[email protected]"
);
	return TRUE;

	}
	
Tina O'Connell
Web Dev & Appgini FAN

Post Reply