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
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");
Hi saman0suke,
Please share the answer. i am also getting the same error but now on Dynamics 365.
Please reply me at earliest.
Thanks
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.
Did not work, any other idea? thanks for the help.
Hi.
Try set the "SetCompany" property on your form's design node to "No"
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.
how u set the allowcrosscompany property . through code ?
Hi
Have you modified the code in excuteQuery method? if so, can you put the code before super()?
I just checked and no one else is trying to set that on code, what else should I check? thanks.
Maybe someone else is doing it, I will take a look at it, what if that's not the case? Thanks!
Regards.
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156