Solved

How do I add customizations to the Bank Deposit Screen?

  • 16 February 2022
  • 3 replies
  • 92 views

Userlevel 5
Badge +1

I’ll preface this by saying I’m just learning to add customizations and have only added very simple ones previously.  This seemed simple too but I’ve run into a problem I’m not sure how to solve.

I am trying to add two default values in the Bank Deposit Screen (CA305000)

I added an event handler for FieldDefaulting on the two fields I want, CashAccountID and in the Add payment dialog the Start Date.

I got the following as a base to add the code but when I try to validate it says:

\App_RuntimeCode\CADepositEntry.cs(27): error CS0246: The type or namespace name 'PaymentFilter' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\CADepositEntry.cs(27): error CS0246: The type or namespace name 'PaymentFilter' could not be found (are you missing a using directive or an assembly reference?)

If I remove the section for the StartDate it publishes OK but when I click to add a new Bank Deposit it says: Error: An error occurred during processing of the field CashAccountID: Object reference not set to an instance of an object..

Am I missing something else I need to add at at the top for the PaymentFilter bit in the dialog to work?

Do I need to do something special because the CashAccountID field is a lookup field(probably not the right term)? 

I’ve added customizations to other screens and been able to just add my bit of code at the bottom without changing other stuff, but that was for ‘normal’ fields.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Data;
using PX.Data.WorkflowAPI;
using PX.Objects.Common;
using PX.Objects.AR;
using PX.Objects.AP;
using PX.Objects.CM.Extensions;
using PX.Objects.GL;
using PX.Objects.CS;
using PX.Objects.Extensions.MultiCurrency;
using PX.Objects;
using PX.Objects.CA;

namespace PX.Objects.CA
{
public class CADepositEntry_Extension : PXGraphExtension<CADepositEntry>
{
#region Event Handlers

protected void PaymentFilter_StartDate_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (PaymentFilter)e.Row;

if (row == null) return;

// Added by PP on 16/2/2022 **
e.NewValue = DateTime.Parse("2022/01/01");
}



protected void CADeposit_CashAccountID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (CADeposit)e.Row;

if (row == null) return;

// Added by PP on 16/2/2022 **
e.NewValue = "1100";
}
}
}

Thanks for any advice.

 

Phil

icon

Best answer by jinin 16 February 2022, 17:49

View original

3 replies

Userlevel 7
Badge +11

Hi @ppowell 

Please add the namespace “ using static PX.Objects.CA.CADepositEntry; “. This is missed on the above code.

Userlevel 7
Badge +17

Hi, @ppowell  Addition above Jini’s comment, here is the source code you are looking for and just add do publish and verify. 

 

using System;
using PX.Data;
using static PX.Objects.CA.CADepositEntry;

namespace PX.Objects.CA
{
public class CADepositEntry_Extension : PXGraphExtension<CADepositEntry>
{
#region Event Handlers

protected void PaymentFilter_StartDate_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (PaymentFilter)e.Row;

if (row == null) return;

// Added by PP on 16/2/2022 **
e.NewValue = DateTime.Parse("2022/01/01");
}

protected void CADeposit_CashAccountID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (CADeposit)e.Row;

if (row == null) return;

// Added by PP on 16/2/2022 **
e.NewValue = "1100";
}

#endregion
}
}

 

Userlevel 5
Badge +1

Hi @ppowell 

Please add the namespace “ using static PX.Objects.CA.CADepositEntry; “. This is missed on the above code.

Thanks! working perfectly after adding that line.

 

Phil

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 — 2024  Acumatica, Inc. All rights reserved