I have seen a couple of other post like this but none that quite answer my question. We populate a UDF (County) from a set of valid values which create a drop down list. The UDF correctly has the description and not the code. However a simple query (below) returns the value number and not the description
SELECT T1.CardName , T0.U_city , T0.U_County
FROM OCPR T0 INNER JOIN OCRD T1 ON T1.CardCode = T0.CardCode
Hi Ralph
Try the following:
SELECT T1.CardName , T0.U_city , T0.U_County, T2.Descr
FROM OCPR T0 INNER JOIN OCRD T1 ON T1.CardCode = T0.CardCode, UFD1 T2, CUFD T3
WHERE T0.U_City = T2.FldValue and T2.TableID = 'OCPR' and T2.FieldID = 2 and T3.TableID = 'OCPR' and T3.FieldID = 2
Replace FieldID 2 with the ID of the T0.U_city field. Look in CUFD to get the internal ID for the field.
The only problem is you have 2 UDF's, so you will have to find a way of bringing both Description Fields back, possibly using a UNION clause or something along those lines. Test with just one first and see if it returns the correct values.
Kind regards
Peter Juby
Hi Ralph
SAP Business One automatically displays the name and not code for the valid values. There are 2 tables you can look at. Firstly CUFD and secondly UFD1. The code and name for valid values is stored in UFD1.
Kind regards
Peter Juby
This is an example of how to display the UDF field description instead of the UDF field Code. In my example the udf field is in the OITM file
How to display the name instead of the codes for user defined fields:
SELECT T0.ItemCode, (select T1.[Descr] from UFD1 T1 join dbo.[CUFD] T2 on T2.[TableId] = T1.[TableId] and T2.[FieldId] = T1.[FieldID] and T2.[TableId] = 'OITM' and T2.[AliasId] = 'YourUdfFieldName' where T1.[FldValue] = T0.[U_YourUdfFieldName]) FROM [dbo].[OITM] T0
Hi Keith
Ralph is looking for the description of the valid values and not the UDF itself. It seems quite involved though to achieve this as the UFD1 only links to CUFD and all the fields are using internal references (numeric). The sample I sent him works for one UDF and not 2. Any ideas?
Kind regards
Peter Juby
I just wrote a blog article on how to solve this exact problem: http://goo.gl/xuZZtV
Just join UFD1 and you can pull the description that way,
Mike
Add a comment