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
Best answer by jinin
View original