Search code examples
acumatica

How can I keep a user field from coming through on a Journal Entry release function?


I have a customization to the Journal Transactions screen where I've added a user field to the grid (GLTran). When the Release function is initiated, it adds lines as it should - but it populates the user field with the values I had in the original lines, and I don't want this to happen. How can I intercept this process (I've looked at the source code and I can't see any functions I can use) to prevent this from happening?

I've tried the RowInserting / RowInserted events to set the field to null or blank, but this does nothing.

Thanks much -


Solution

  • From Acumatica support - an override of the Release process needs to be added to the Journal Entry BLC extension code, adding Event handlers as follows:

        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
        [PXOverride]
        public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
        {
            PXGraph.InstanceCreated.AddHandler<PostGraph>((graph) =>
            {
                graph.RowPersisting.AddHandler<GLTran>((sender, e) =>
                {
                    var gltran = e.Row as GLTran;
                    if (gltran != null)
                    {
                        var gltranext = PXCache<GLTran>.GetExtension<GLTranExt>(gltran);
                        gltranext.UsrProject = null;
                    }
                });
            });
    
            return baseMethod(adapter);
        }
    

    Thanks much, Cesar!