This topic is locked

Email with List Values and Not column ID

6/23/2012 3:25:24 AM
PHPRunner General questions
A
Abhijeet author

Hello Room,
I have following email code and email is going successfully on phprunnner 5.3 build 7474.
$email="--rbegin--test@test.com--rend--,abc@test.com";

$from="--rbegin--srm@hodekindia.com--rend--";

$msg="New Test certificate Loaded";

$subject="--rbegin--New Material Test Certificate Loaded--rend--";
foreach($values as $field=>$value)

{

if(!IsBinaryType(GetFieldType($field)))

$msg.= $field." : ".$value."\r\n";

}
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
Below is the table where record is inserted and email is sent. So the event is email on add record on this table
CO NUMBER(2)

CODE CHAR(2)

DOCNO NUMBER(5)

ITEMID VARCHAR2(5)

FILENAME VARCHAR2(100)

CUSTID VARCHAR2(5)

GRN NUMBER(5)

PARTYINVNO VARCHAR2(10)

FILENAME1 VARCHAR2(100)

QTY NUMBER(15,2)
Now my problem is itemid field is a internal id and I want to see itemname in the email. Same with custid field it is the customer name i want in email.
sql code for itemname is select itemname from itemmst where co = [userid] and itemcd = :new.itemid

sql code for customer name is select acname from accmst where co = [userid] and accid = :new.custid
how to integrate this code in email and send email with partname and customer name instead of customer id and part id. As users get confused when they see

internal part id and customer id.
Please help.

C
cgphp 6/23/2012

In the "After successfull login" event, enter the following code:

$_SESSION['userid'] = $data['userid'];


In the "After record added" event, enter the following code:

$rs = CustomQuery("select itemname from itemmst where co = ".$_SESSION['userid']." and itemcd = ".$values['itemid']);

$record = db_fetch_array($rs);

$itemname = $record['itemname'];
$rs = CustomQuery("select acname from accmst where co = ".$_SESSION['userid']." and accid = ".$values['custid']);

$record = db_fetch_array($rs);

$acname = $record['acname'];