Skip to main content
Answer

Change Default Doc type value in payments and application screen

  • August 25, 2021
  • 2 replies
  • 275 views

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.

Best answer by Naveen Boga

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;
}
}
}

 

 

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • August 26, 2021

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;
}
}
}

 

 


  • Author
  • Freshman II
  • August 26, 2021

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