Gossamer Forum
Home : Products : DBMan : Customization :

Validate Records + Relational Mod

Quote Reply
Validate Records + Relational Mod
Hello,

I am using JPD's relational mod as well as Validate record mod.

My Databases are as follows
1) Dealer (Member)
2) PO (Purchase Order)
3) SOPF (Sales Order Processor)

My Problem is as follows;

Validate record mod is supposed to send email to the "owner" of the record. My problem is that I have included a Validate Mod in PO database and the owner Email is in Dealer Database,

How do I make the Validate Mod to send an email to the owner

Thanks

Regards

Vijay
Quote Reply
Re: Validate Records Relational Mod In reply to
You will need to add your switch codes above such as:

&switch_to_dealer;
%rec2 = &get_record($rec{'UserID'});
&switch_to_po;
open (MAIL, "$mailprog") or &cgierr("unable to open mail program");

of course matching your database names exactly Smile

You will want to put this in place for both the approval email and the rejection email.

Don't forget to change the line:
print MAIL "To: $rec2{$db_email_field}\n";

Hope this helps Smile

Quote Reply
Re: Validate Records Relational Mod In reply to
Sorry LoisC, Frown

It did not work for me.

Here Is my Partial Cade

sub html_add_success {
# --------------------------------------------------------
# The page that is returned upon a successful addition to
# the database. You should use &get_record and &html_record
# to verify that the record was inserted properly and to make
# updating easier.
%rec=&get_record($in{$db_key});

open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New PO at $html_title\n\n";
print MAIL "A new Purchase Order was added at $html_title with the following information:\n\n";
print MAIL "Please visit the site validate the Purchase Order\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;

open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $rec2{$db_email_field}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New PO at $html_title\n\n";
print MAIL "You Have placed a new Purchase Order at $html_title with the following information:\n\n";
print MAIL "This Purchase Order will be validated by Webmaster and you will be intimated accordingly\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;


I even tried
in po.cfg (my cfg file for po db)
# Fieldname that contains the email address of the user
$db_email_field = $rec2{'Email'};

and in po_html.pl

open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $db_email_field}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New PO at $html_title\n\n";
print MAIL "You Have placed a new Purchase Order at $html_title with the following information:\n\n";
print MAIL "This Purchase Order will be validated by Webmaster and you will be intimated accordingly\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;
&html_print_headers;
print qq|


I need Help again !

Regards

Vijay
Quote Reply
Re: Validate Records Relational Mod In reply to
I thought your original message was referring to sub validate_records in your db.cgi file so you could receive email when a record was validated?

Did the solution above work for that?

What worked for me in sub html_add_success was using:

%rec=&get_record($in{$db_key});
&html_record_long(%rec);

or if not using short/long mod:

%rec=&get_record($in{$db_key});
&html_record(%rec);

Sending a confirmation of the addition to yourself should work with the above changes hopefully Smile

If you are going to send a copy to the user however, you need to add your switch routine so it can get their email address from your dealer database. I don't know what your exact switch codes are but it would look similar to this:

#######################
&switch_to_dealer;
%rec2 = &get_record($rec{'UserID'});
&switch_to_po;
#######################

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $rec2{'Email'}\n";
print MAIL "From: $admin_email\n";
etc.

Hope this helps.