0

I have created a Custom PXSelector Control Field in Acumatica Invoices and Memos(ScreenID=AR301000). The control is in the Document Details Grid. The selector load values well but the problem is if a user adds another row to the Document Details Grid, the value selected in the previous row self clears??? Below is my code:

using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CM;
using PX.Objects.Common.Discount.Attributes;
using PX.Objects.Common.Discount;
using PX.Objects.Common;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.GL.DAC.Abstract;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.TX;
using PX.Objects;
using System.Collections.Generic;
using System.Diagnostics;
using System;

namespace PX.Objects.AR
{
  public class ARTranExt : PXCacheExtension<PX.Objects.AR.ARTran>
  {
    #region UsrResource
    [PXDBInt]
    [PXUIField(DisplayName="Resource")]
    [PXSelector(
      typeof(Search<CSAttributeDetail.valueID,Where<CSAttributeDetail.attributeID, Equal<AttributeExtender.resource>>>),
      typeof(CSAttributeDetail.valueID),
      typeof(CSAttributeDetail.description),
      SubstituteKey = typeof(CSAttributeDetail.valueID)
    )]
    public virtual int? UsrResource { get; set; }
    public abstract class usrResource : PX.Data.BQL.BqlInt.Field<usrResource> { }
    #endregion
  }
  public static class AttributeExtender
  {
    public const string Resource = "RESOURCE";
    public class resource : PX.Data.BQL.BqlString.Constant<resource>
    {
       public resource() : base(Resource) {; }
    }
                           
  }
}    

What could possibly be the problem?

1 Answers1

1

CSAttributeDetail.ValueID is defined as an nvarchar(10) in the database. As per your selector, you are trying to assign the nvarchar(10) (string) value to an integer field. I tried this, and it works if your attribute's ValueID is numeric, but you did not indicate what your ValueID's values are. Since I can reproduce this behavior by adding attribute details that are character based codes instead of numbers, I suspect your attribute's detail values are letters instead of numbers.

Either make sure your attribute details' ValueID is always an integer value, or (preferably) change your user field to an nvarchar(10).

Attribute Details defined Invoices and Memos - Example of Issue Reported

Unrelated, but worth noting... Since your PXSelector returns CSAttributeDetail.valueID to be stored in the field, you don't need to define a SubstituteKey of the same exact field.

CSAttributeDetail.ValueID

Brian Stevens
  • 1,826
  • 1
  • 7
  • 16