Loading ...

Acumatica: redirection to screens from grid or how to enable hyper-link for grid fields

Hello developers,

Today I want to share with you the way how to enable hyper-link functionality from grids to another screen.

To enable a redirection to screen from the hyper-link in the grid, first we must be sure at two points:

  1. Field in grid has [PXSelector] attribute from foreign DAC table
  2. Foreign table (DAC) has [PXPrimaryGraph] attribute

If both steps are ready, then we go to the Customization Editor screen and add a needed field to Levels, like on screenshot:

Then we need enable “AllowEdit=True” attribute on field, publish customization and check results:

Results from the Sales Order screen, a hyper link with redirection function from grid to Sales Person screen:

One more example with custom screen:

First step, it is to develop the custom DAC with [PXPrimaryGraph()] attribute.

Example of source code of custom DAC and graph:

[Serializable]
[PXCacheName("AP TariffHTS Code DAC")]
[PXPrimaryGraph(typeof(APTariffHTSCodeEntry))]
public class APTariffHTSCode : AuditSystemFields, IBqlTable
{
    #region HSTariffCode
    [PXDBString(30, IsKey = true, InputMask = "9999.99.9999", IsUnicode = true)]
    [PXUIField(DisplayName = "Tariff Code", Visibility = PXUIVisibility.SelectorVisible)]
    public virtual string HSTariffCode { getset; }
    public abstract class hSTariffCode : BqlString.Field<hSTariffCode> { }
    #endregion
 
    #region  HSTariffCodeDescr
    [PXDBString(255, IsUnicode = true)]
    [PXUIField(DisplayName = "Tariff Code Description", Visibility = PXUIVisibility.SelectorVisible)]
    public virtual string HSTariffCodeDescr { getset; }
    public abstract class hSTariffCodeDescr : BqlString.Field<hSTariffCodeDescr> { }
    #endregion
 
    #region NoteID
    [PXNote()]
    public virtual Guid? NoteID { getset; }
    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    #endregion
}
 
public class APTariffHTSCodeEntry : PXGraph<APTariffHTSCodeEntry, APTariffHTSCode>
{
    [PXFilterable]
    public SelectFrom<APTariffHTSCode>.View TariffHTSCodeView;
}

 

One more example with custom screen:

First step, it is to develop the custom DAC with [PXPrimaryGraph()] attribute.

Example of source code of custom DAC and graph:

[Serializable]
[PXCacheName("Vendor Duty DAC")]
public class INVendorDuty : AuditSystemFields, IBqlTable
{
    #region InventoryID
    [PXDBInt(IsKey = true)]
    [PXParent(typeof(SelectFrom<InventoryItem>.Where<InventoryItem.inventoryID.IsEqual<inventoryID.FromCurrent>>))]
    [PXDBDefault(typeof(InventoryItem.inventoryID))]
    [PXUIField(DisplayName = "Inventory ID", Visible = false)]
    public virtual int? InventoryID { getset; }
    public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
    #endregion
 
    #region VendorID
    [VendorNonEmployeeActive(IsKey = true, DisplayName = "Vendor ID",
        Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(Vendor.acctName), Filterable = true)]
    [PXDefault]
    public virtual int? VendorID { getset; }
    public abstract class vendorID : PX.Data.BQL.BqlInt.Field<vendorID> { }
    #endregion
 
    #region HSTariffCode
    [PXDBString(30, IsUnicode = true)]
    [PXUIField(DisplayName = "Tariff Code")]
    [PXSelector(typeof(SearchFor<APTariffHTSCode.hSTariffCode>))]
    [PXDefault(typeof(InventoryItem.hSTariffCode))]
    public virtual string HSTariffCode { getset; }
    public abstract class hSTariffCode : PX.Data.BQL.BqlString.Field<hSTariffCode> { }
    #endregion
 
    #region CountryID
    [PXDBString(100)]
    [PXUIField(DisplayName = "Country")]
    [Country]
    [PXDefault(typeof(SearchFor<Address.countryID>.Where<Address.bAccountID.IsEqual<vendorID.FromCurrent>>), PersistingCheck = PXPersistingCheck.Nothing)]
    public virtual string CountryID { getset; }
    public abstract class countryID : PX.Data.BQL.BqlString.Field<countryID> { }
    #endregion
 
    #region DutyPct
    [PXUIField(DisplayName = "Duty, %")]
    [PXDBDecimal(2, MinValue = 0, MaxValue = 100)]
    [PXDefault(TypeCode.Decimal, "0.000000", PersistingCheck = PXPersistingCheck.Nothing)]
    public decimal? DutyPct { getset; }
    public abstract class dutyPct : PX.Data.BQL.BqlDecimal.Field<dutyPct> { }
    #endregion
 
    #region EffectiveDate
    [PXDBDate()]
    [PXDefault(typeof(AccessInfo.businessDate), PersistingCheck = PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName = "Effective Date")]
    public virtual DateTime? EffectiveDate { getset; }
    public abstract class effectiveDate : PX.Data.BQL.BqlDateTime.Field<effectiveDate> { }
    #endregion
 
    #region NoteID
    [PXNote()]
    public virtual Guid? NoteID { getset; }
    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    #endregion
}

 

Then we customize another screen (in my case it is Stock Item) and we are going to have redirection to our custom screen (Tariff / HTS Code). So we develop new DAC with field (public string HSTariffCode) that has [PXSelector()] attribute. This DAC we put as a grid to the Stock Item screen on new tab.

Here is example of custom DAC with Parent-Child connection to Stock Item screen:

[Serializable]
[PXCacheName("Vendor Duty DAC")]
public class INVendorDuty : AuditSystemFields, IBqlTable
{
    #region InventoryID
    [PXDBInt(IsKey = true)]
    [PXParent(typeof(SelectFrom<InventoryItem>.Where<InventoryItem.inventoryID.IsEqual<inventoryID.FromCurrent>>))]
    [PXDBDefault(typeof(InventoryItem.inventoryID))]
    [PXUIField(DisplayName = "Inventory ID", Visible = false)]
    public virtual int? InventoryID { getset; }
    public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
    #endregion
 
    #region VendorID
    [VendorNonEmployeeActive(IsKey = true, DisplayName = "Vendor ID",
         Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(Vendor.acctName), Filterable = true)]
    [PXDefault]
    public virtual int? VendorID { getset; }
    public abstract class vendorID : PX.Data.BQL.BqlInt.Field<vendorID> { }
    #endregion
 
    #region HSTariffCode
    [PXDBString(30, IsUnicode = true)]
    [PXUIField(DisplayName = "Tariff Code")]
    [PXSelector(typeof(SearchFor<APTariffHTSCode.hSTariffCode>))]
    [PXDefault(typeof(InventoryItem.hSTariffCode))]
    public virtual string HSTariffCode { getset; }
    public abstract class hSTariffCode : PX.Data.BQL.BqlString.Field<hSTariffCode> { }
    #endregion
 
    #region CountryID
    [PXDBString(100)]
    [PXUIField(DisplayName = "Country")]
    [Country]
    [PXDefault(typeof(SearchFor<Address.countryID>.Where<Address.bAccountID.IsEqual<vendorID.FromCurrent>>), PersistingCheck = PXPersistingCheck.Nothing)]
    public virtual string CountryID { getset; }
    public abstract class countryID : PX.Data.BQL.BqlString.Field<countryID> { }
    #endregion
 
    #region DutyPct
    [PXUIField(DisplayName = "Duty, %")]
    [PXDBDecimal(2, MinValue = 0, MaxValue = 100)]
    [PXDefault(TypeCode.Decimal, "0.000000", PersistingCheck = PXPersistingCheck.Nothing)]
    public decimal? DutyPct { getset; }
    public abstract class dutyPct : PX.Data.BQL.BqlDecimal.Field<dutyPct> { }
    #endregion
 
    #region EffectiveDate
    [PXDBDate()]
    [PXDefault(typeof(AccessInfo.businessDate), PersistingCheck = PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName = "Effective Date")]
    public virtual DateTime? EffectiveDate { getset; }
    public abstract class effectiveDate : PX.Data.BQL.BqlDateTime.Field<effectiveDate> { }
    #endregion
 
    #region NoteID
    [PXNote()]
    public virtual Guid? NoteID { getset; }
    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    #endregion
}

After, we must replicate all steps in Customization Editor for Levels that I describe above (add field “HSTariffCode“ to Levels, enable AllowEdit attribute on it).

Here results, new Tab with grid on Stock Item screen and redirection hyper-link to our custom screen:

If you need enable redirection from a field on the Form to another screen, this approach is described by Acumatica team in T210-220 courses.

Wish you enjoy customizing Acumatica!