Conditional display of a record

Hi all,

I’m new to Nav (v 2009) and have a little question.

I’ve created a table where messages can be stored so that all users can see them. This table has the data per company-property on “No” so they are available in all companies. Now i’ve made a page wich contains these messages and integrated it in a role center page, so far so good.

What i want to do now is to add a condition to the page that only the lines where companyname is empty (=All companies) or where companyname equals the companyname in table 79 (company information) will be displayed on this page.

Any suggestions?

Thanks in advance.

Pieter-Jan

Hi and welcome to forum!

Never mind you are a beginner - this exact question is about coding, so I moved your post to Dev forum, there it’ll faster catch attention.

Not being a programmer myself, I can’t give you exact code, but the idea is to set a filter in code upon opening your page.
That’s not difficult, many derived Forms (now Pages) when opened as “drill-down” from some other form, use this approach.

You can get the current company by using the COMPANYNAME keyword.

You can use SourceTableView property of the form,

WHERE(Company Name=FILTER (’’|COMPANYNAME))

I think you are interested in COMPANYNAME , and NOT table 79 (company information).

CompanyNam which is displayed on top of NAV database screen may be different than companyname in table 79 (company information)

Thanks for the suggestions. It’s indeed a better idea to use the COMPANYNAME-databasefunction.

I’ve tried to use Dhan’s suggestion to add WHERE(NameOfCompany=FILTER(COMPANYNAME|’’)) in the sourcetableview, but my idea is that NAV doesn’t recognize The COMPANYNAME-funtion as a database-function, but as a value. Do I have to specifie somewhere that the function i use is a databasefunction or something (I even tried this in a form without positive result)?

Finaly i needed to type one line of code in the OnOpenPage-trigger of my page. In this code, i check if the NameOfCompany-field of my table equals the COMPANYNAME (Databasefunction) or the constant ‘ALL’. Using databasefunctions in the sourcetableview-property is not possible.

SETFILTER(NameOfCompany,’%1|%2’, COMPANYNAME, ‘ALL’)