Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

The form datasource query object does not support changing its AllowCrossCompany property

(0) ShareShare
ReportReport
Posted on by 2,890

Hi, I'm working in AX 2012 R2, and I need to display records from different companies so I set the property on each datsource to allow crossCompany, however I'm getting the error as soon as the executeQuery gets is called:

The form datasource query object does not support changing its AllowCrossCompany property after the form has executed the query.

I would appreciate your help on fixing this issue. The records are retrieved fine but the error is showing up. Thanks.

*This post is locked for comments

  • Suggested answer
    Pradeep_Prakash Profile Picture
    Pradeep_Prakash 715 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    Hi,

    You need to enable the cross-company property on the data source and use the below code for the filter.

    For cross comapny:

    query.clearCompanyRange();

    for specific company:

    query.addcompanyRange("Company name");

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    Hi saman0suke,

    Please share the answer. i am also getting the same error but now on Dynamics 365.

    Please reply me at earliest.

    Thanks

  • Mic Kan Profile Picture
    Mic Kan on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    You are right, I faced with this problem lastly and followed Your suggesion with overwrite DS executeQuery method:

    public void executeQuery()
    {;

    this.query().allowCrossCompany(true); //this is literal for this example, change in practice to sth more functionally
    //
    super();

    }

    You don't need change CrossCompanyAutoQuery properies at form at all.

  • saman0suke Profile Picture
    saman0suke 2,890 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    Did not work, any other idea? thanks for the help.

  • Suggested answer
    Jonathan  Halland Profile Picture
    Jonathan Halland 11,306 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    Hi.

    Try set the "SetCompany" property on your form's design node to "No"

  • saman0suke Profile Picture
    saman0suke 2,890 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    The code after super() does not make any reference to crossCompany, just regular code, and the property is being set on the datasource by using the property CrossCompanyAutoQuery. Thanks.

  • Amir Nazim Profile Picture
    Amir Nazim 5,994 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    how u set the allowcrosscompany property . through code ?

  • Pradeep Itnal Profile Picture
    Pradeep Itnal 3,248 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    Hi

    Have you modified the code in excuteQuery method? if so, can you put the code before super()?

  • saman0suke Profile Picture
    saman0suke 2,890 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    I just checked and no one else is trying to set that on code, what else should I check? thanks.

  • saman0suke Profile Picture
    saman0suke 2,890 on at
    RE: The form datasource query object does not support changing its AllowCrossCompany property

    Maybe someone else is doing it, I will take a look at it, what if that's not the case? Thanks!

    Regards.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans