Skip to main content
Answer

Unable to enter new record's Surrogate key

  • November 4, 2024
  • 9 replies
  • 96 views

Forum|alt.badge.img+1

I am not sure what I have done wrong but when I try to enter a new record for this custom DAC the key field blanks as soon as I am done entering and change focus to any other field.

My expectation is that the value entered would be the new key for the new record.

 

Is this field annotated improperly ? Attached is the whole DAC     

        #region AssetCD
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
[PXDefault]
[PXUIField(DisplayName = "Asset")]
[PXSelector(typeof(Search<assetCD>), new Type[]
{
typeof(assetCD),
typeof(assetTypeID),
typeof(assetStatus),
typeof(description),
}, DescriptionField = typeof(description))]
public virtual string AssetCD { get; set; }
public abstract class assetCD : PX.Data.BQL.BqlString.Field<assetCD> { }
#endregion

 

Best answer by Leif

The problem was from two UI element (PXFormView & PXTab) referencing the same view.

I added the ‘DocumentSettings’ view and used it for the PXTab element and that fixed the issue.

 

        public SelectFrom<GPAsset>.View Document;

        public PXSelect<GPAsset, Where<GPAsset.assetID, Equal<Current<GPAsset.assetID>>>> DocumentSettings;

9 replies

Forum|alt.badge.img+8
  • Captain II
  • November 5, 2024

Adding ValidateValues = false to your PXSelector might help.

 

 


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • November 5, 2024

ValidateValues did not help.


DipakNilkanth
Pro III
Forum|alt.badge.img+13

Hi @Leif,

Could you please replace Default attribute of AssetCD [PXDefault] to below snippet along with ValidateValues = false?

    [PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]

Hope, it helps!


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • November 7, 2024

No change. I am stumped.

 


Forum|alt.badge.img+8
  • Captain II
  • November 7, 2024

Hi @Leif 

 

could you please try changing your field declaration to this:

#region AssetCD
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
//[PXDefault]
[PXUIField(DisplayName = "Asset")]
[PXSelector(
typeof(assetCD),
typeof(assetTypeID),
typeof(assetStatus),
typeof(description),
DescriptionField = typeof(description), ValidateValue = false)]
public virtual string AssetCD { get; set; }
public abstract class assetCD : PX.Data.BQL.BqlString.Field<assetCD> { }
#endregion

let us know if that changes anything

Aleks


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • November 7, 2024

No changes.

I also removed all code from the graph, so it only has one view.

 

 


Forum|alt.badge.img+8
  • Captain II
  • November 7, 2024

What’s your database like? 
 

have you set the column as a key?


Forum|alt.badge.img+8
  • Captain II
  • November 7, 2024

Also, it might be worth debugging in Visual Studio, seeing if that pops any errors. If not it’s a database issue


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • Answer
  • November 17, 2024

The problem was from two UI element (PXFormView & PXTab) referencing the same view.

I added the ‘DocumentSettings’ view and used it for the PXTab element and that fixed the issue.

 

        public SelectFrom<GPAsset>.View Document;

        public PXSelect<GPAsset, Where<GPAsset.assetID, Equal<Current<GPAsset.assetID>>>> DocumentSettings;