Solved

User input disappearing on trying to save.

  • 14 August 2023
  • 2 replies
  • 42 views

Userlevel 4
Badge

Hello everyone, I created a table with the following script.

CREATE TABLE [dbo].[GDLFAVehicleDetails](
[CompanyId] [int] NOT NULL,
[AssetId] [int] NOT NULL,
[VehicleRegNo] [nvarchar](50) NOT NULL,
/***other fields left out***/

CONSTRAINT [PK_GDLFAVehicleDetails] PRIMARY KEY CLUSTERED
(
[CompanyId] ASC,
[AssetId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [IX_GDLFAVehicleDetails_1] UNIQUE NONCLUSTERED
(
[VehicleRegNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

I needed to make VehicleRegNo to accept only unique values
so I added Iskey= true on the DAC as shown below;
However when I add the Iskey=true value the user input disappears, when I remove it user input does not disappear on the UI and user is able to save the input entered.

What could be the issue?

 

   #region VehicleRegNo
[PXDBString(50,IsKey =true, IsUnicode = true)]
[PXDefault]
[PXUIField(DisplayName = "Vehicle Reg No.")]
public virtual string VehicleRegNo { get; set; }

public abstract class vehicleRegNo : PX.Data.BQL.BqlString.Field<vehicleRegNo>
{
}
#endregion

Kindly asist
Any kind of response will be highly appreciated.

icon

Best answer by Joe Schmucker 14 August 2023, 18:23

View original

2 replies

Userlevel 6
Badge +3

@Michael Ndungi 

I would remove the constraint for VehicleRegNo in the SQL table and just use [PXCheckUnique].  That has worked for me.  The other option would be to add VehicleRegNo to the primary key.  I don’t see why you would need a separate constraint for that field.  Based on your description, the combination of AssetId and VehicleRegNo should always be unique.  If you do that, you wouldn’t need to use [PXCheckUnique].  However, using [PXCheckUnique] allows you to provide a nice message if they try to save a duplicate.  [PXCheckUnique(typeof(VehicleRegNo ), ErrorMessage = "My message")]

Userlevel 5
Badge +1

Hi Michael,

I remember two unique attributes that Acumatica allow to use in DAC:

[PXUnique]
[PXCheckUnique]

 

Try it, I guess that first attribute will help you.

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