Solved

Change Default Doc type value in payments and application screen

  • 25 August 2021
  • 2 replies
  • 86 views

Userlevel 1

I’m trying to change the default doc type value of “payment” to “Prepayment” in payments and application screen.

I have tried to use cache attached method, field defaulting and row selected events to override the default value in the graph, but those are not working to change default value of Doc Type.

I have tried below code. Can anyone point me in the right direction to set the doc type value to prepayment. 

public class ARPaymentEntry_Extension : PXGraphExtension<ARPaymentEntry>
{
//1st method
#region Using Cached attached
[PXMergeAttributes(Method = MergeMethod.Append)]
//[PXRemoveBaseAttribute(typeof(ARPaymentType.ListExAttribute))]
[PXRemoveBaseAttribute(typeof(ARPaymentType.ListAttribute))]
//[PXRemoveBaseAttribute(typeof(ARDocType.ListAttribute))]
[PXDefault(ARPaymentType.Prepayment)]
[NewARListAttribute]
// [PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, Enabled = true, TabOrder = 0)]
//[PXFieldDescription]
protected virtual void ARPayment_DocType_CacheAttached(PXCache sender)
{

}

public new class NewARListAttribute : PXStringListAttribute
{
public NewARListAttribute()
: base(
new string[] { ARPaymentType.Prepayment, ARPaymentType.Payment, ARPaymentType.CreditMemo, ARPaymentType.Refund, ARPaymentType.VoidRefund, ARPaymentType.VoidPayment, ARPaymentType.SmallBalanceWO },
new string[] { Messages.Prepayment, Messages.Payment, Messages.CreditMemo, Messages.Refund, Messages.VoidRefund, Messages.VoidPayment, Messages.SmallBalanceWO })
{ }
}

#endregion


//////[PXMergeAttributes(Method = MergeMethod.Append)]
//////[PXRemoveBaseAttribute(typeof(ARPaymentType.ListExAttribute))]
//////[PXDefault(ARDocType.Prepayment)]
//////[XMSListAttribute]
//////protected virtual void ARRegister_DocType_CacheAttached(PXCache sender)
//////{

//////}


//2nd
#region Using setdefault in row selected event
//protected virtual void ARPayment_RowSelected(PXCache cache, PXRowSelectedEventArgs e,PXRowSelected baseEvent)
//{
// baseEvent?.Invoke(cache, e);
// PXDefaultAttribute.SetDefault<ARPayment.docType>(cache, ARPaymentType.Prepayment);
//}

#endregion


//3rd
#region Using field defaulting event

//public virtual void ARPayment_DocType_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
//{
// e.NewValue = "PPM";
//}
#endregion

}

Thanks in advance.

icon

Best answer by Naveen B 26 August 2021, 07:23

View original

2 replies

Userlevel 7
Badge +10

Hi @ssamboju12  I just tried with FieldDefaulting event and I can able to change the default DOCTYPE to Prepayment.

Please find the code below for your reference. 

    public class ARPaymentEntryExt : PXGraphExtension<ARPaymentEntry>
{
protected virtual void ARPayment_DocType_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
ARPayment row = e.Row as ARPayment;
if (row != null)
{
e.NewValue = ARDocType.Prepayment;
}
}
}

 

 

Userlevel 1

@Naveen B Yes it worked. Thanks for the Help!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved