When I click + to get a new record, the first field is not being cleared (cache not cleared?)

  • 22 June 2022
  • 3 replies

Userlevel 4

I have a form with two selector fields.  I want to store the two values in a custom table.  The selector fields work and I can select values and save the record.  But when I click + to create a new record, the first field still contains the previously saved value.  I THINK that the cache is not being cleared when I click +.

This is the form after selecting values:

Click Save and the record saves.

After clicking +

If I lookup a value (any value) for the service type field and click save, I get


If I click Refresh on the browser, I get a clean screen that will let me add a new record.

Note that if I navigate to existing records and make changes, they do get saved properly.

Is there some hack I can do to clear the cache when I click the + ?


The graph only contains one thing, the view:

	public class SSGCRRecordServiceTypeLinks : PXGraph<SSGCRRecordServiceTypeLinks, SSGCRServTypeRecTypeXR>

public SelectFrom<SSGCRServTypeRecTypeXR>.View ServTypeRecTypeLinks;

This is the DAC for the table:

[PXCacheName("Record Type / Service Type XR")]
public class SSGCRServTypeRecTypeXR : IBqlTable

#region ID
public virtual int? ID { get; set; }
public abstract class iD : PX.Data.BQL.BqlInt.Field<iD> { }

#region RecordTypeID
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Record Type")]
SubstituteKey = typeof(SSGCRRecordType.recordTypeCD),
DescriptionField = typeof(SSGCRRecordType.description))]
public virtual int? RecordTypeID { get; set; }
public abstract class recordTypeID : PX.Data.BQL.BqlInt.Field<recordTypeID> { }

#region ServiceTypeID
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Service Type")]
SubstituteKey = typeof(SSGCRServiceType.serviceTypeCD),
DescriptionField = typeof(SSGCRServiceType.description))]
public virtual int? ServiceTypeID { get; set; }
public abstract class serviceTypeID : PX.Data.BQL.BqlInt.Field<serviceTypeID> { }

#region IsActive
[PXUIField(DisplayName = "Active")]
public virtual bool? IsActive { get; set; }
public abstract class isActive : PX.Data.BQL.BqlBool.Field<isActive> { }

#region CreatedByID
public virtual Guid? CreatedByID { get; set; }
public abstract class createdByID : PX.Data.BQL.BqlGuid.Field<createdByID> { }

#region CreatedByScreenID
public virtual string CreatedByScreenID { get; set; }
public abstract class createdByScreenID : PX.Data.BQL.BqlString.Field<createdByScreenID> { }

#region CreatedDateTime
public virtual DateTime? CreatedDateTime { get; set; }
public abstract class createdDateTime : PX.Data.BQL.BqlDateTime.Field<createdDateTime> { }

#region LastModifiedByID
public virtual Guid? LastModifiedByID { get; set; }
public abstract class lastModifiedByID : PX.Data.BQL.BqlGuid.Field<lastModifiedByID> { }

#region LastModifiedByScreenID
public virtual string LastModifiedByScreenID { get; set; }
public abstract class lastModifiedByScreenID : PX.Data.BQL.BqlString.Field<lastModifiedByScreenID> { }

#region LastModifiedDateTime
public virtual DateTime? LastModifiedDateTime { get; set; }
public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }

#region Tstamp
public virtual byte[] Tstamp { get; set; }
public abstract class tstamp : PX.Data.BQL.BqlByteArray.Field<tstamp> { }

#region Noteid
public virtual Guid? Noteid { get; set; }
public abstract class noteid : PX.Data.BQL.BqlGuid.Field<noteid> { }

This is the table in SQL:

CREATE TABLE [dbo].[SSGCRServTypeRecTypeXR](
[CompanyID] [int] NOT NULL,
[id] [int] IDENTITY(1,1) NOT NULL,
[RecordTypeID] INT NOT NULL,
[ServiceTypeID] INT NOT NULL,
[IsActive] [bit] NULL,
[CreatedByID] [uniqueidentifier] NOT NULL,
[CreatedByScreenID] [char](8) NOT NULL,
[CreatedDateTime] [datetime] NOT NULL,
[LastModifiedByID] [uniqueidentifier] NOT NULL,
[LastModifiedByScreenID] [char](8) NOT NULL,
[LastModifiedDateTime] [datetime] NOT NULL,
[tstamp] [timestamp] NOT NULL,
[NoteID] [uniqueidentifier] NULL,
[CompanyID] ASC,
--[id] ASC
[ServiceTypeID] ASC
) ON [primary]




Best answer by Leonardo Justiniano 22 June 2022, 23:26

View original

3 replies

Userlevel 4

Hi @joe21 


The only key of the record is your identity column ID. Please set is as

[PXDBIdentity(IsKey = true)]


Remove the attribute IsKey from the other columns.

Userlevel 4

Hi @Leonardo Justiniano 

Mindboggling.  By making the changes you suggested, it fixed the problem.  The ID field is an identity field in the table.  I have a constraint on the table for the Companyid, RecordTypeID and ServiceTypeID fields.  It would seem intuitive that the RecordTypeID and ServiceTypeID fields should be marked as IsKey = true.  Does that mean that we just rely on SQL constraints to keep from inserting duplicates?

The only other strange thing (at least right now :-)) is that when I click new, the Active checkbox is not checked.  When the record saves, it saves with Active as 1 in the DB.  As soon as you click save, the check box is checked (probably because it is redisplaying the current record with the value from the DB).

Is there something wrong with this field in my DAC?

        #region IsActive
        [PXUIField(DisplayName = "Active")]
        public virtual bool? IsActive { get; set; }
        public abstract class isActive : PX.Data.BQL.BqlBool.Field<isActive> { }
When you click new, the cache is apparently setting that field value to true but the display on the screen is not showing as checked.  

EDIT: this seems to fix the Active checkbox, but seems unecessary

        protected virtual void _(Events.RowInserted<SSGCRServTypeRecTypeXR> e)
            var row = (SSGCRServTypeRecTypeXR)e.Row;
            if (row == null) return;
            row.IsActive = true;


Thank you for the fix!  I spent hours trying to figure this out.


Userlevel 4

Hi @joe21 


[PXDefault(true)] should be it. Please look at the field layout properties. Maybe a wrong setting.


Glad to help!


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 — 2022  Acumatica, Inc. All rights reserved