Показать сообщение отдельно
Старый 03.11.2016, 03:34   #1  
Blog bot is offline
Blog bot
Участник
 
25,646 / 848 (80) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: Changing a Relationship Precedence in Dynamics AX
Источник: https://stoneridgesoftware.com/chang...n-dynamics-ax/
==============

Have you ever been in a scenario where a data source has more than one relationship to a table it is being linked to? I have. It wasn’t a problem until I wanted the second relationship to take priority.

So the real question is, how to specify what relationship should the table use?





In my example, on the InventTable I have multiple relationships defined. Please note though:

InventTable.AlcholoManufacturerID_RU == VendTable.AccountNum InventTable.PrimaryVendorId == VendTable.AccountNum

On my form: EcoResProductDetailsExtended, I added VendTable as a data source.

Well, how does AX know which relationship I want take precedence? By default, AX uses the first one. In this case, the AlcoholManufacturer_RU relationship takes precedence.





To change what relationship takes precedence I overloaded the init() method.





  1. First, you must tell the data source what relationship you want to use.
vendtable_ds.joinRelation("PrimaryVendTable"); 2. Second, you must make the relationship the active relationship.
VendTable_ds.linkActive(); 3. Third, you must execute the query.
vendtable_ds.executeQuery(); </p> It is important to note, this must all be done before the super(). By following these simple steps, you will set a tables relationship precedence on a data source with more than one defined relationship.

Your init() method should look like the following.

public void init() { vendtable_ds.joinRelation("PrimaryVendTable"); VendTable_ds.linkActive(); vendtable_ds.executeQuery(); super(); }



Источник: https://stoneridgesoftware.com/chang...n-dynamics-ax/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.