Skip to Content
0
Former Member
Feb 21, 2011 at 05:05 AM

Error in Query - Help needed!

32 Views

Dear All,

I need help regarding the query. The requirement is that the user wants to populate the Telephone No. or email of the Bill to address of CRD1 into a UDF in Sales Order. The condition is if both telephone no. and email address is availbal,e we should show telephone number. Email should be displayed only when the telephone no. field is blank.

Accordingly, we created 2 UDFs in the BP -Addresses for Telephone and mail, U_TelNo and U_Email. We also created a UDF in Sales Order, U_Comm. All the fields are declared as alphanumeric only.

We wrote a FMS to retrieve the values but surprisingly, the query is only pulling out the first character of the result and populating. For example, if the telephone no. is 991-323-1123, it is pulling out only 9 and similarly for the email.

Here is the query:

Declare @Tel varchar

Declare @Email varchar

Set @Tel = (Select U_TelNo from CRD1 where CRD1.CarDCode = $[$-4.1.0] AND CRD1.Address = $[$-226.1.0] AND CRD1.AdresType = 'B')

Set @Email = (Select U_Email from CRD1 where CRD1.CarDCode = $[$-4.1.0] AND CRD1.Address = $[$-226.1.0] AND CRD1.AdresType = 'B')

If @Tel is NOT NULL

Select @Tel

Else

Select @Email

Where are we going wrong?

Thanks and regards,

Bharath S