Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Translating data to an email address Post Reply Post New Topic
Author Message
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Topic: Translating data to an email address
     Posted: 15 Jan 2014 at 11:18pm
Hi
I am looking for some guidance. We need to compare different database fields and create the output based on the comparison when there is a match. However, 2 of the fields is first and last name and the other field has full name (which has been calculated via our ERP system). We then want to translate the calculated name to the contacts email address. Our report displays the calculated name (calculated via our ERP system) but we need to translate this into the email address. Example of what we are trying to archive below.

The report shows the following calculated "John Smith" and table1 contains files Firstname, Lastname and email. We need the calculated data to translate and pull through eh table1.email.

e.g. John Smith will show jsmith@example.com

I have pulled all first name and emails through on a sub report but cannot link the correct details with the calculated field, and basically I was trying to match the first and last name fields to the calculated filed and then display the email address for this field (using a formula). if there is another way to achieve this, please advise.

There is a reason for the calculated field as the name can change based on the order.
thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Jan 2014 at 7:44am
not following this exactly...
are all 3 fields in the same table and you want to know any row where
(table1.fname+table1.lname+'@ example.com') <> table1.emailaddress
?
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 16 Jan 2014 at 11:07am
Hi
our ERP system calculates the full name of the person who placed the order, crystal reports then uses this calculated field to display the full name which isn't actually part of the table (it appears as calc_name, this is what we will call it for this example), we will call this table2. We don't have the license for developing for our ERP system to create the calculated field for puling through the email, the same way it calculates the full name. The 3 fields, which we will call table1, are the first name, last name and email address associated with the first and last name. I need to get crystal reports to match the calculated field, which is the full name (e.g. John Smith)with the fields in table1 so i can display the email address associated with the displayed full name. Table1 doesn't have a field having the full name.
so basically the report displays the calculated field, which is the persons full name. We need a formula to get the table1 data to be associated with the calculated field data so i can display the correct email address. Hope i have expanded the explanation more.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Jan 2014 at 11:34am
hmmmm...
Crystal is really just a display for data, it does not store it or manufacture it.
One can manipulate data before it comes into Crystal (e.g stored procedures) or you can change the way it appears once it gets in (e.g formulas) but it really does not alter the data.
 
I am confused by what and where you are trying to compare the data?
table2.calc_name is not really part of a table? Even if it is being calculated from other data that data has to exist somehwere.
Table1 has first name, last name and email fields but no customer ID?.
 
I find it odd that a customer ordering system does not use a a unique identifier for each 'customer' and that would be the way to link table to table if data is stored across tables.
What am I missing?
Are you trying to join 2 tables or just change the way data from one table is appearing in crystal (not a table)?
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 16 Jan 2014 at 9:32pm
Yes crystal is really the front end to display data.
Our ERP system has the option to add calculated fields (if we have the SDK license it will allow us to add more calculated fields with data) so crystal will see the calculated field under the table (where we add the calculated field) but it isn't actually a field within that table, that's what I meant when I said "it is not part of the table" because it is not (if I were to browse the actual database I would not see calc_billcontct as a field under the ShipHead table, which is table 2 in my previous posts). The calculated field calculates it from the other table within the report data definitions.
Ok, the calculated field in the report data definitions appears as calc_bilcontct and the calculated field is pulling data from the CustCnt table (table 1 in my previous post). I have added the table 1 (within the report data definitions on the ERP system) so we can see the CustCnt table within the report. So the calculated field will display the full name of the Contact, and because we cannot get data from adding calculated fields in our ERP system (which would have been the way to do it but we don't have the license), I basically need a formula within crystal to get the data from CustCnt table (email address) by using the Calc_Bilcontct displayed data.
I have tried different formulas but it doesn't seem to achieve what I want it to do.

Below is examples of formulas I have tried
//@subreport {ShipHead.Calc_BilContct}
//if ("{CustCnt.FirstName}+{CustCnt.LastName}"={ShipHead.Calc_BilContct})then {CustCnt.EMailAddress}
//IF
// {CustCnt.FirstName} + {CustCnt.LastName}
//= {ShipHead.Calc_BilContct} then {CustCnt.EMailAddress}
// else ""
//IF ISNULL({CustCnt.FirstName}) OR ISNULL({CustCnt.LastName}) THEN
   // "Other"
//Else
    //{CustCnt.EMailAddress}
//if ("{CustCnt.FirstName}" and "{CustCnt.LastName}") is ({ShipHead.Calc_BilContct}) then {CustCnt.EMailAddress} else "no email"
//{CustCnt.FirstName}+{CustCnt.LastName}=""

//if {CustCnt.FirstName} + " " + {CustCnt.LastName} = {ShipHead.Calc_BilContct} then {CustCnt.EMailAddress} else "err"

//if "{CustCnt.FirstName}"+"{CustCnt.LastName}" in{ShipHead.Calc_BilContct} then "{CustCnt.EMailAddress}" else "err"

In summary, the report displays the name of the Bill to contact (as explained, is the calculated field) but I need a formula to check the displayed data of the calculated field and then match it to the CustCnt information so I can then display the email address for the displayed contact. E.g. The calculated field displays John Smith, the formula checks John Smith against the First and Last name within the CustCnt table, when a match is found, it will display the email address from the CustCnt table for that contact.

Hope this makes a bit more sense.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Jan 2014 at 4:26am

I think you are trying to create a field to use as a link between the tables.

I still will suggest that there is already a link in the DB to accomplish this much easier. If there was not then the ERP would not be able to create the calculated field because it could properly link itself to the customer data.

Sometimes you need to use intermediate tables to get to what you want.

Like a customer table to an order to a bill table to a payment table.

In this example, perhaps the customer id is only attached to the customer and the order tables but you want to show the customer name and payments. You still join (daisy chain) all 4 tables as needed and only use fields from the customer and bill tables.

 

it is possible to do what you want but consider using a command object to create the field you want (the concatenated name) and then use that as a join to {ShipHead.Calc_BilContct}

This is still risky as any like names will join and you will get multiple emails results that would be incorrect.

Your current approach of doing this in the report only can be done but it would be brutal on the resources.

I assume you did not link the two tables in the report source. Therefore you will get a Cartesian data set from it.

You can then use a filter to remove rows using a select statement similar to your if-then formula above.

Or you can go the route of the sub report and use a formula field to link on from main to sub report.

All of these options still are risky and I think making a simple process more complicated than it needs to be. However, I do not know your data set so

if you cannot find a proper table join to get the data set you need if you want to choose one of the above approaches we could walk through it.

 



Edited by DBlank - 17 Jan 2014 at 4:27am
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 19 Jan 2014 at 9:55pm
Thanks for replies
I have tried intermediate tables to achieve the desired result. I will try different tables to see if I can achieve it. I appreciate your comments. thanks
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum