Hello again, I think this comes in the standard, is the 5067 report. The report has only one Dataitem, the Customer table, and a filter for customers that shows the available balance of each and how to print a list of tags. I made a modification so that when you run the report it automatically sent by mail to every customer balance as follows:
IF Customer.GET ( "No.") THEN BEGIN
IF "E-Mail "<>'' THEN BEGIN
CodeMail.NewMessage ( "E-Mail ",''," Notice - Customer No. '+" No. "
'Please note that the amount to declare'
+ 'Is' + value,'', TRUE);
END;
END;
CodeMail is codeunit Mail
It works perfectly, but it gets the mail field from the Customer table. Now I want that it gets the mail address of the person in the department of accounting firm contact type for this customer. The table that contains the data is the 5067-Contact Job Responsibility but I can`t link it to get the email address of the department. Can someone please help me?.
Many thanks in advance.
Comments
To get the contact link through the Contact Business Relation and the lookup the contact table.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
relation.INIT;
IF relation.GET("No.") THEN;
relation is the Contact business relation table.
And it gets it, but don't show the fields from that table on customer body, what is wrong please?.
Thank you very much for your help.
You will need extra code - the GET function is only for the primary key. Try something like...
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thanks.
relation is actually a C/AL function - use a different variable name e.g. BusRelation
The E-Mail address is store on the contact table not the Contact Business Relation table so you will need the Contact table as well
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thanks you very mucho for your help.
We have more work to do to link this in.
So far we have go the company contact for a customer. The next step is to find all the related contacts and then find the one(s) with the correct "Job Responsibility Code".
so
This will build up a string text with emailaddress;emailaddress;emailaddress
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
EMailText
BusRelation
PersonContact
ContactJobResponsibility
My version is in spanish and I can't find some tables.
Thanks again.
EMailText - is a text variable to store the E-Mail address (or more than one if required)
BusRelation - is a record variable for table 5054
PersonContact - is a record variable for table 5050 (a second variable to loop type person contact)
ContactJobResponsibility - - is a record variable for table 5067
Hope this clears it up for you.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thanks for your time.
Firstly, Gald to Help
On my version the E-Mail is stored on the contact table and not the Contact Job Responsibility table. If it is a flowfield then you need to do a CALCFIELDS to get the value. If you post your code I'll have a look.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
contacto is Contact table
"Correo-e" is the e-mail field from ContactJobResponsibility table that I want to show
relacion is Contact Business Relation table
Thanks for help.
The CALCFIELDS was in the wrong place (and I've done a bit of a tidy )
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thanks for all your dedication.
Had another look at the code and found a problem it should read
A contact can have more than one job responsibility.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Well, it continues without work. It's true that a contact can have more than one job responsibility, i'm filtering by DEP. CONTABILIDAD (accounting department in english), also can be more than a contact in the accountig department, but showing only one is enough. I'll test the code again.
Thanks for your help.
I spotted another error
IF contacto.GET( relacion."Contact No." ) THEN
should be
IF contacto.GET( BusRelation."Contact No." ) THEN
Fingers crossed
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Well, thanks really for help.
Not sure what you mean. The code is designed to get the information off the Contact Job Responsibility table using a variable ContactJobResponsibility. It then stores this in a Variable EMailText and this is what you need to print. If you put a section for the Contact Job Responsibility table then completely different code is needed.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thank you very much for your help.
Thank you for help
You only need the customer dataitem on the report and the corrected code. You will have to declare variables for the tables used i.e. BusRelation, contacto, PersonContact and ContactJobResponsibility. Put the code in the OnAfterGetRecord trigger of the Customer dataitem and then in the print section add a textbox with SourceExpr of EMailText.
Hope this clears it up for you.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html