How to create seperate selector for composite primary key... Like OrderNbr and Revision nbr ... I am facing issue in selecting the value from Order Nbr selector, it set the values if revision nbr field is default value otherwise Order nbr selector cant set the values in Revision nbr field.. how to set both the fields on selecting the value from any of the selector.
1 Answers
The solution is to have one selector query reference the other key field.
Example for Sales Order which uses two selector control OrderType and OrderNumber:
// User selects the OrderType first
[PXSelector(typeof(Search<SOOrderType.orderType>))]
// OrderNumber Selector reference current OrderType value in selector query
[PXSelector(typeof(Search<SOOrder.orderNbr,
Where<SOOrder.orderType, Equal<Current<this.orderType>>>>)]
You also need to set the AutoRefresh property to True so the selector re-execute the query each time the selector dialog is re-opened. This ensure that it is properly filtered by order type in the example.
<px:PXSelector ID="edOrderType" runat="server" DataField="OrderType"
AutoRefresh="True" CommitChanges="True" DataSourceID="ds">
<px:PXSelector ID="edOrderNbr" runat="server" DataField="OrderNbr"
AutoRefresh="True" CommitChanges="True" DataSourceID="ds">
It is strictly not possible to have a single selector dialog select a record which requires more than one field to be unique. In those special cases, an alternative solution is to add another field which is unique and to select the record based on that field. Note that for your use case two selector controls is preferable.
To implement this alternative solution add an Identity type column in database as the unique field and decorate the matching DAC field with PXDBIdentity attribute. Keep the other keys as is. The identity field will auto-increment automatically and guarantee the uniqueness based on a single field which is required for the selector to function properly.