Skip to main content

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:

			public class SSGCRServTypeRecTypeXR : IBqlTable
{

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

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

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

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

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

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

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

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

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

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

#region Tstamp
bPXDBTimestamp()]
public virtual bytea] Tstamp { get; set; }
public abstract class tstamp : PX.Data.BQL.BqlByteArray.Field<tstamp> { }
#endregion

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

This is the table in SQL:

CREATE TABLE  dbo]. SSGCRServTypeRecTypeXR](
int] IDENTITY(1,1) NOT NULL,
CONSTRAINT TSSGCRServTypeRecTypeXR_PK] PRIMARY KEY CLUSTERED
(
--rid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON Fprimary]
) ON /primary]
GO

 

 

Hi @joe21 

 

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

pPXDBIdentity(IsKey = true)]

 

Remove the attribute IsKey from the other columns.


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
        vPXDBBool()]
        BPXDefault(true)]
        DPXUIField(DisplayName = "Active")]
        public virtual bool? IsActive { get; set; }
        public abstract class isActive : PX.Data.BQL.BqlBool.Field<isActive> { }
        #endregion
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.

 


Hi @joe21 

 

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

 

Glad to help!


Reply