web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

View created with dynamic range value selects only "Dat" company data

(0) ShareShare
ReportReport
Posted on by 1,215

Hi,

Greetings!

I have created a view with tables "Ledger" and "CompanyInfo".

On the "CompanyInfo" data source I added a range as "DataArea = (CurrentCompany())"

The expected behavior is to select the current company records, instead the view returns only "Dat"

company records.

Regards,

Abhinay

I have the same question (0)
  • Abhinay Tharwal Profile Picture
    1,215 on at
    RE: View created with dynamic range value selects only "Dat" company data

    Hi,

    I changed the order of the tables in the datasource, started with the table with property "save data per company" set to true, and the view got filtered at runtime.

    "currentCompany()" did not help.

    Regards,

    Abhinay

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: View created with dynamic range value selects only "Dat" company data

    I guess the range is part of the view definition which gets synced to the database. This means that currentCompany() is interpreted during sync time, not runtime. So it doesn't work dynamically. You can verify this by looking at the view definition in SQL server.

    This means you need to add your range value in x++ code in runtime, instead of having it in the view definition.

  • Abhinay Tharwal Profile Picture
    1,215 on at
    RE: View created with dynamic range value selects only "Dat" company data

    Hi Nikolaos,

    Thank you for your reply.

    Please refer the link

    [quote]What if you remove this range, does it then return only data from current company?[/quote]

    It returns the records from all the companies.

    Regards,

    Abhinay

  • Sumit Loya Profile Picture
    2,230 on at
    RE: View created with dynamic range value selects only "Dat" company data

    Hi Abhinay,

    To diagnose this, I suggest you create a view with following datasources  added. Ledger -> CompanyInfo linking Ledger.PrimaryForLegalEntity with CompanyInfo.RecId. Then in the view you add a field Ledger.Name and  CompanyInfo.DataArea field.

    First write a job to loop through this view and display both the fields in info. Please test this and let me know what your result is.

    Then when you use this view in your form, you can add range for this view as qbds.addRange(fieldNum(View, DataArea)).value(queryValue(curExt()));

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: View created with dynamic range value selects only "Dat" company data

    What if you remove this range, does it then return only data from current company? I would expect it to do that.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,239

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 767 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 672 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans