I need to handle a new status on ARIncoice for legacy reasons and added therefore a custom field called cegEStatus in a DAC extension of ARInvoice.
[PXCopyPasteHiddenFields(typeof(cegEStatus))]
public class ARInvoiceEIExtBase : PXCacheExtension<ARInvoice>
{
#region CegEStatus
[PXDBString(50, IsUnicode = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Electronic Status", IsReadOnly = true)]
[EiStatuses.List]
public virtual string CegEStatus { get; set; }
public abstract class cegEStatus : BqlString.Field<cegEStatus> { }
#endregion
}
This field was also added to AR301000.
A new DAC has then been created to store the values assigned to the status of a given ARInvoice over time.
public class EiInvoiceRegisteredStatus : IBqlTable
{
public static bool IsActive() => PXAccess.FeatureInstalled<FeaturesSetExt.cegEInvoicingOutgoing>() || PXAccess.FeatureInstalled<FeaturesSetExt.cegEInvoicingIncoming>();
#region DocType
public abstract class docType : BqlString.Field<docType> { }
/// <summary>
/// [key] Type of the document.
/// </summary>
/// <value>
/// Possible values are: "INV" - Invoice, "ACR" - Credit Adjustment, "ADR" - Debit Adjustment,
/// "CHK" - Check, "VCK" - Void Check, "PPM" - Prepayment, "REF" - Vendor Refund,
/// "QCK" - Quick Check, "VQC" - Void Quick Check.
/// </value>
[PXDBString(3, IsKey = true, IsFixed = true)]
[PXDefault()]
[ARDocType.List()]
[PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, Enabled = false, TabOrder = 0)]
[PXFieldDescription]
public virtual String DocType { get; set; }
#endregion
#region RefNbr
public abstract class refNbr : BqlString.Field<refNbr> { }
/// <summary>
/// [key] Reference number of the document.
/// </summary>
[PXDBString(20, IsUnicode = true, IsKey = true, InputMask = "")]
[PXDefault()]
[PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.SelectorVisible, TabOrder = 1)]
[PXSelector(typeof(Search<ARInvoice.refNbr, Where<ARInvoice.docType, Equal<Optional<docType>>>>), Filterable = true)]
//[PXFieldDescription]
public virtual String RefNbr { get; set; }
#endregion
#region Code
[PXDBString(50, IsUnicode = true, IsKey = true, InputMask = "")]
[EiStatuses.List]
[PXUIField(DisplayName = "Electronic Status")]
public string Code { get; set; }
public abstract class code : BqlString.Field<code> { }
#endregion
#region RegisteredDateTime
public abstract class registeredDateTime : BqlDateTime.Field<registeredDateTime> { }
[PXDBDateAndTime(IsKey = true, DisplayMask ="G", UseTimeZone = true)]
[PXUIField(DisplayName = "Registered Date")]
public virtual DateTime? RegisteredDateTime { get; set; }
#endregion
#region RegisteredByID
public abstract class registeredByID : BqlGuid.Field<registeredByID> { }
[PXDBGuid()]
[PXUIField(DisplayName = "Registered By")]
[PXSelector(
typeof(Search<Users.pKID>),
typeof(Users.username),
typeof(Users.displayName),
SubstituteKey = typeof(Users.username),
DescriptionField = typeof(Users.displayName)
)]
public virtual Guid? RegisteredByID { get; set; }
#endregion
//+Audit fields
}
Finally, I created new custom graph and screen (ARInvoiceRegisteredStatusEntry)
that displays the status history for an invoice. So far so good.
public class ARInvoiceRegisteredStatusEntry : PXGraph<ARInvoiceRegisteredStatusEntry>
{
#region Views
public PXFilter<EiInvoiceRegisteredStatusFilter> Filter;
[PXFilterable]
public SelectFrom<EiInvoiceRegisteredStatus>
.Where<EiInvoiceRegisteredStatus.docType.IsEqual<EiInvoiceRegisteredStatusFilter.docType.FromCurrent>
.And<EiInvoiceRegisteredStatus.refNbr.IsEqual<EiInvoiceRegisteredStatusFilter.refNbr.FromCurrent>>>
.OrderBy<EiInvoiceRegisteredStatus.registeredDateTime.Desc>
.View.ReadOnly RegisteredStatus;
#endregion
public class EiInvoiceRegisteredStatusFilter : IBqlTable
{
#region DocType
public abstract class docType : BqlString.Field<docType> { }
/// <summary>
/// [key] Type of the document.
/// </summary>
/// <value>
/// Possible values are: "INV" - Invoice, "ACR" - Credit Adjustment, "ADR" - Debit Adjustment,
/// "CHK" - Check, "VCK" - Void Check, "PPM" - Prepayment, "REF" - Vendor Refund,
/// "QCK" - Quick Check, "VQC" - Void Quick Check.
/// </value>
[PXString(3, IsKey = true, IsFixed = true)]
[PXDefault()]
[ARDocType.List()]
[PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, TabOrder = 0, IsReadOnly = true)]
[PXFieldDescription]
public virtual String DocType { get; set; }
#endregion
#region RefNbr
public abstract class refNbr : BqlString.Field<refNbr> { }
/// <summary>
/// [key] Reference number of the document.
/// </summary>
[PXString(20, IsUnicode = true, IsKey = true, InputMask = "")]
[PXDefault()]
[PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.SelectorVisible, TabOrder = 1, IsReadOnly =true)]
public virtual String RefNbr { get; set; }
#endregion
}
}
What I would like to implement is the possibility for the user to open my new screen from the AR301000 screen, by clicking on the new field. Therefore, I wrote an action that do the job.
public PXAction<ARInvoice> DisplayEStatuses;
[PXButton(Category = Messages.ElectronicInvoicing, DisplayOnMainToolbar = false)]
[PXUIField(DisplayName = "Display E-statuses")]
protected virtual void displayEStatuses()
{
ARInvoice arInvoice = Base.Document.Current;
using (IFlexLog logger = new EiInvoiceActionLog("refreshStatus", arInvoice))
using (logger.NewParagraph($"DISPLAY STATUSES: Invoice {arInvoice.DocType}.{arInvoice.RefNbr}"))
{
graph = PXGraph.CreateInstance<ARInvoiceRegisteredStatusEntry>();
graph.Filter.Current = CreateEiStatusesFilter(arInvoice);
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters[nameof(EiInvoiceRegisteredStatusFilter.DocType)] = arInvoice.DocType;
parameters[nameof(EiInvoiceRegisteredStatusFilter.RefNbr)] = arInvoice.RefNbr;
throw new PXRedirectRequiredException(graph, true, "Electronic statuses", parameters) { Mode = PXBaseRedirectException.WindowMode.NewWindow };
}
}
private static EiInvoiceRegisteredStatusFilter CreateEiStatusesFilter(ARInvoice arInvoice)
{
return new EiInvoiceRegisteredStatusFilter()
{
DocType = arInvoice.DocType,
RefNbr = arInvoice.RefNbr,
};
}
Is there any way to trigger this action clicking on my custom field in AR301000 ?