0
votes

I am looking to customize the allow add new button to point to a correct graph/Screen. I have a DAC that links to a non-stock item from a setup page. The selector filters out to only show non-stock items. When I use the AllowAddNew=True, it shows the pencil with a link to the Stock Items page. Is there a way to force it to go to the non-stock item page?

Here is an example of one of my DAC fields that has this issue.

#region DefCylDepInventoryID 
[PXDBInt]
[PXUIField(DisplayName = "Default Cylinder Deposit Item")]
[PXSelector(typeof(Search<
    InventoryItem.inventoryID, 
    Where2<
        Where<InventoryItem.stkItem, Equal<False>>, 
        And<Where<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.unknown>>>>>), typeof(InventoryItem.inventoryID), typeof(InventoryItem.descr), typeof(InventoryItem.itemStatus), DescriptionField = typeof(InventoryItem.descr), SubstituteKey = typeof(InventoryItem.inventoryCD))]
[PXForeignReference(typeof(Field<CYSetup.defCylDepInventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
public virtual int? DefCylDepInventoryID { get; set; }
public abstract class defCylDepInventoryID : PX.Data.BQL.BqlInt.Field<defCylDepInventoryID> { }
#endregion
1
AllowEdit=true in the page is usually the key to adding the link to the item. When empty I think it just opens the correct empty page. Because InventoryItem already indicates the PXPrimaryGraph based on stkItem it should open the correct graph. - Brendan

1 Answers

1
votes

Try to define the selector with the encapsulated [NonStockItem] attribute instead.

Your field would look like this:

#region DefCylDepInventoryID 
[PXUIField(DisplayName = "Default Cylinder Deposit Item")]
[NonStockItem]
[PXRestrictor(typeof(Where<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.unknown>>), "Message")] 
[PXForeignReference(typeof(Field<CYSetup.defCylDepInventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
    public virtual int? DefCylDepInventoryID { get; set; }
    public abstract class defCylDepInventoryID : PX.Data.BQL.BqlInt.Field<defCylDepInventoryID> { }
    #endregion

In theory, this would use the NonStock Item's PXPrimaryGraph, which should redirect you to the right page.