Skip to main content
Solved

Counting Values on Custom Page

  • August 30, 2023
  • 6 replies
  • 153 views

Furkan Zengin
Ultimate Hero (Partner)
Forum|alt.badge.img+21

Hello experts,

I created a new custom LU with couple of fields. One of them is checking duplicate values.

These are my custom LU columns. Please see the SQL code for DUPLICATE column.

 

When I run query on SQL query tool I got the number. Please see below

 

 

But on custom page the number is 0 although the query is the same. What could be wrong.

 

 

thanks

Best answer by Jonas Feigl

I suspect that you have defined the fields “INVOICE_NO” and/or “SUPPLIER” as Persistent Custom fields of type “Reference”? If so you have to check the _DB column instead:

  • WHERE cf$_supplier_db = :cf$_supplier AND cf$_invoice_no_db = :cf$_invoice_no

The reason is the following:

  • For Persistent Custom Fields of type “Reference” the table (_CFT, _CLT) stores the ROWKEY of the referenced record rather than the actual key you are referencing. The ROWKEY is a GUID, i.e. a ‘random’ string of characters and numbers.
  • In the corresponding view (_CFV, _CLV) you then get two columns, a _DB column (e. g. “CF$_SUPPLIER_DB”) which shows the ROWKEY value from the table and the standard column (“CF$_SUPPLIER”) which shows the now converted user friendly value (i.e. the supplier id).
  • As the parameters (:CF$_SUPPLIER / t.CF$_SUPPLIER) come from the table these will contain the ROWKEY
  • Your select statement has its WHERE condition on the view though where it then contains the converted (user friendly) key value. 
  • To fix this you can either change your select statement to select from the table (“i_n_v_r_e_g_clt”) or select form the _db column.

 

Hope this helps!

6 replies

EntNadeeL
Hero (Partner)
Forum|alt.badge.img+10
  • Hero (Partner)
  • 182 replies
  • August 31, 2023

@gumabs 

I have a feeling this might have to do with the datatype you selected for this duplicate field. 

Can you check if its a number?

Cheers


Furkan Zengin
Ultimate Hero (Partner)
Forum|alt.badge.img+21
  • Author
  • Ultimate Hero (Partner)
  • 765 replies
  • August 31, 2023

Hi @EntNadeeL 

Thanks for input. The data type was text and I changed to number. Then refreshed page layout. However the formula is not calculating after the change


EntNadeeL
Hero (Partner)
Forum|alt.badge.img+10
  • Hero (Partner)
  • 182 replies
  • August 31, 2023

@gumabs 

Have you synchronized the logical unit after changing.?

Cheers


Furkan Zengin
Ultimate Hero (Partner)
Forum|alt.badge.img+21
  • Author
  • Ultimate Hero (Partner)
  • 765 replies
  • August 31, 2023

Hi @EntNadeeL 

Yes, I did synchronize but it does not work


Jonas Feigl
Superhero (Employee)
Forum|alt.badge.img+20
  • Superhero (Employee)
  • 266 replies
  • Answer
  • August 31, 2023

I suspect that you have defined the fields “INVOICE_NO” and/or “SUPPLIER” as Persistent Custom fields of type “Reference”? If so you have to check the _DB column instead:

  • WHERE cf$_supplier_db = :cf$_supplier AND cf$_invoice_no_db = :cf$_invoice_no

The reason is the following:

  • For Persistent Custom Fields of type “Reference” the table (_CFT, _CLT) stores the ROWKEY of the referenced record rather than the actual key you are referencing. The ROWKEY is a GUID, i.e. a ‘random’ string of characters and numbers.
  • In the corresponding view (_CFV, _CLV) you then get two columns, a _DB column (e. g. “CF$_SUPPLIER_DB”) which shows the ROWKEY value from the table and the standard column (“CF$_SUPPLIER”) which shows the now converted user friendly value (i.e. the supplier id).
  • As the parameters (:CF$_SUPPLIER / t.CF$_SUPPLIER) come from the table these will contain the ROWKEY
  • Your select statement has its WHERE condition on the view though where it then contains the converted (user friendly) key value. 
  • To fix this you can either change your select statement to select from the table (“i_n_v_r_e_g_clt”) or select form the _db column.

 

Hope this helps!


Furkan Zengin
Ultimate Hero (Partner)
Forum|alt.badge.img+21
  • Author
  • Ultimate Hero (Partner)
  • 765 replies
  • August 31, 2023

Hi @Jonas Feigl 

Thanks for reply. I changed query to table and it worked. Thanks for detailed explanation. I understand the logic behind now.

 

 

@EntNadeeL thanks again for your input and correcting me for data type.

 

Regards