I have a lookup which displays records from other company(not the current company).
But when I select the value am getting the following error : The value in the field is not found in the relating table".
I think it is checking for the value selected n the current company.But it should check in the the other company from which the record is displayed.
Can anyone help me on this please?
If this is the case, you can use the 'CrossCompany' keyword in your query.
Below example would help you creating your cross company related query:
QueryBuildDataSource qbds ;
q = new query();
qbds = q.addDataSource(tablenum(CustTable));
qr = new QueryRun(q);
ct = qr.get(tablenum(CustTable));
If your table is company-specific and there is a relation to validate, AX correctly validates the value. It's the same as if you type in a value - if it doesn't exist in the current company, AX prevents you from breaking data consistency. It's irrelevant that the value would be correct in another company.
I was using the above code in my Queries.But still I am getting that error.Though am using the crossCompany in my code it is validating for that value in the current company.
I have checked it and my table is not company specific one.
The key is in the relation. Define a composite relation that will use DataAreaId and the field you're interested in, so AX will know from which company is should take data. Be sure that no other relation is used (typically there is a relation on EDT that you don't want to use).
If you do it right, even the lookup will work automatically.
How can we do this? I couldn't understand. This is my table:
User should first select company and select CustAccount from related company.
Try the Below link
I just did already same like yours, but I would like to do this with just create a relation and don't supress validate method so I just curious about Martin's solution.
@metin: What I meant was creating two fields: one with EDT SelectableDataArea and one with CustVendAC or something (not CustAccount - the relation defined there seems to be used even if IngoreEDTRelation is set to Yes). Then you would create a new table relation pointing to DataAreaId and AccountNum fields of CustTable. The lookup for customer account would be then filtered by data area ID.
It works (tested in AX2012), but not so well as it should. The lookup shows right values when selecting an account for the first time, but if you want to change it later, the lookup seems to include some values from the current company. I'm not going to investigate that further.
Thank you... :)