Skip to main content

Hi all 

I hope you all guys are doing good I am getting null values in default columns in table when I trying to save a record in screen you can find a shot below. I hope your support and presence

Thanks in advance.

 

Hi @ShahidaValiSyed04  Hope you are using same as the below DAC fields. Please verify 

#region CreatedByID

PXDBCreatedByID()]
public virtual Guid? CreatedByID { get; set; }
public abstract class createdByID : BqlGuid.Field<createdByID> { }

#endregion

#region CreatedByScreenID

PXDBCreatedByScreenID()]
public virtual string CreatedByScreenID { get; set; }
public abstract class createdByScreenID : BqlString.Field<createdByScreenID> { }

#endregion

#region CreatedDateTime

PXDBCreatedDateTime()]
PXUIField(DisplayName = "Created Date Time")]
public virtual DateTime? CreatedDateTime { get; set; }
public abstract class createdDateTime : BqlDateTime.Field<createdDateTime> { }

#endregion

#region LastModifiedByID

PXDBLastModifiedByID()]
public virtual Guid? LastModifiedByID { get; set; }
public abstract class lastModifiedByID : BqlGuid.Field<lastModifiedByID> { }

#endregion

#region LastModifiedByScreenID

PXDBLastModifiedByScreenID()]
public virtual string LastModifiedByScreenID { get; set; }
public abstract class lastModifiedByScreenID : BqlString.Field<lastModifiedByScreenID> { }

#endregion

#region LastModifiedDateTime

PXDBLastModifiedDateTime()]
PXUIField(DisplayName = "Last Modified Date Time")]
public virtual DateTime? LastModifiedDateTime { get; set; }
public abstract class lastModifiedDateTime : BqlDateTime.Field<lastModifiedDateTime> { }

#endregion

#region Tstamp

PXDBTimestamp()]
PXUIField(DisplayName = "Tstamp")]
public virtual bytet] Tstamp { get; set; }
public abstract class tstamp : BqlByteArray.Field<tstamp> { }

#endregion

 


Hi @ShahidaValiSyed04  Hope you are using same as the below DAC fields. Please verify 

#region CreatedByID

PXDBCreatedByID()]
public virtual Guid? CreatedByID { get; set; }
public abstract class createdByID : BqlGuid.Field<createdByID> { }

#endregion

#region CreatedByScreenID

PXDBCreatedByScreenID()]
public virtual string CreatedByScreenID { get; set; }
public abstract class createdByScreenID : BqlString.Field<createdByScreenID> { }

#endregion

#region CreatedDateTime

PXDBCreatedDateTime()]
PXUIField(DisplayName = "Created Date Time")]
public virtual DateTime? CreatedDateTime { get; set; }
public abstract class createdDateTime : BqlDateTime.Field<createdDateTime> { }

#endregion

#region LastModifiedByID

PXDBLastModifiedByID()]
public virtual Guid? LastModifiedByID { get; set; }
public abstract class lastModifiedByID : BqlGuid.Field<lastModifiedByID> { }

#endregion

#region LastModifiedByScreenID

PXDBLastModifiedByScreenID()]
public virtual string LastModifiedByScreenID { get; set; }
public abstract class lastModifiedByScreenID : BqlString.Field<lastModifiedByScreenID> { }

#endregion

#region LastModifiedDateTime

PXDBLastModifiedDateTime()]
PXUIField(DisplayName = "Last Modified Date Time")]
public virtual DateTime? LastModifiedDateTime { get; set; }
public abstract class lastModifiedDateTime : BqlDateTime.Field<lastModifiedDateTime> { }

#endregion

#region Tstamp

PXDBTimestamp()]
PXUIField(DisplayName = "Tstamp")]
public virtual bytey] Tstamp { get; set; }
public abstract class tstamp : BqlByteArray.Field<tstamp> { }

#endregion

 

Yes @Naveen B  what I have to do now? these all are getting null  thanks for responding


@ShahidaValiSyed04  Have you written any logic on the SAVE action and cleared any caches?


 


@ShahidaValiSyed04  Have you written any logic on the SAVE action and cleared any caches?


 

No I haven’t Written anything in save action But I created a button in that button when a user clicked on button it’s have to create a new record and have to generate all ID’s of new record

Here my Graph

 


@ShahidaValiSyed04  Can you please share your code here, instead of screenshot.


@ShahidaValiSyed04  Can you please share your code here, instead of screenshot.

Ok

 

 public PXAction<SSPAgreement> Revision;

        PXButton(CommitChanges = true), PXUIField(DisplayName = "Revision",

          MapEnableRights = PXCacheRights.Select,

          MapViewRights = PXCacheRights.Select)]

        public void revision()

        {

            // Acuminator disable once PX1050 HardcodedStringInLocalizationMethod oJustification]

            WebDialogResult result = Agreements.Ask(ActionsMessages.Warning, PXMessages.LocalizeFormatNoPrefix("Are you sure you want to create a new revision?"),

                MessageButtons.OKCancel, MessageIcon.Information, true);

            //SSPAgreement row = Agreements.Current;

            SSPAgreement dacObject = new SSPAgreement();

            if (result == WebDialogResult.OK)

            {

               // Agreements.View.RequestRefresh();

                //Agreements.View.Cache.Clear();

                //Agreements.View.Cache.ClearQueryCache();

                SSPAgreement agreementsOldRecord = Agreements.Current;

                SSPAgreement agreementsNewRecord = new SSPAgreement();

                agreementsNewRecord.TemplateCode = agreementsOldRecord.TemplateCode;

                agreementsNewRecord.Revision =(int)(agreementsOldRecord.Revision+1);

                agreementsNewRecord.AgreeNbr = (string)(agreementsOldRecord.AgreeNbr);

                agreementsNewRecord.Active = agreementsOldRecord.Active;

                //agreementsNewRecord.Descr = agreementsOldRecord.Descr;

                //agreementsNewRecord.LastModifiedByID = agreementsOldRecord.LastModifiedByID;

               // Agreements.Insert(agreementsNewRecord);

                Agreements.Update(agreementsNewRecord);

                Agreements.Cache.PersistInserted(agreementsNewRecord);

                throw new PXRedirectRequiredException(PXGraph.CreateInstance<SSPAgreementMaint>(agreementsNewRecord.TemplateCode), "Agreements") { Mode = PXBaseRedirectException.WindowMode.Same };

            }

           

        }

        protected void SSPAgreement_RowSelected(PXCache cache, PXRowSelectedEventArgs e)

        {

            var row = (SSPAgreement)e.Row;

            if (row.Active.GetValueOrDefault())

                this.Revision.SetEnabled(true);

            else

                this.Revision.SetEnabled(false);

            //PXUIFieldAttribute.GetCustomAttribute<SSPAgreement.>

        }


@ShahidaValiSyed04  Can you check with the below code

public PXAction<SSPAgreement> Revision;
PXButton(CommitChanges = true), PXUIField(DisplayName = "Revision", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public void revision()
{
WebDialogResult result = Agreements.Ask(ActionsMessages.Warning, PXMessages.LocalizeFormatNoPrefix("Are you sure you want to create a new revision?"),MessageButtons.OKCancel, MessageIcon.Information, true);

if (result == WebDialogResult.OK)
{
if (Agreements.Current != null)
{
SSPAgreement agreementsOldRecord = Agreements.Current;
SSPAgreement agreementsNewRecord = new SSPAgreement();
agreementsNewRecord.TemplateCode = agreementsOldRecord.TemplateCode;
agreementsNewRecord.Revision = (int)(agreementsOldRecord.Revision + 1);
agreementsNewRecord.AgreeNbr = (string)(agreementsOldRecord.AgreeNbr);
agreementsNewRecord.Active = agreementsOldRecord.Active;
Agreements.Cache.Insert(agreementsNewRecord);
this.Actions.PressSave();
throw new PXRedirectRequiredException(PXGraph.CreateInstance<SSPAgreementMaint>(agreementsNewRecord.TemplateCode), "Agreements") { Mode = PXBaseRedirectException.WindowMode.Same };
}
}
}

 


Hi @Naveen B 

its saving record on the same record But not creating a new One

 


Hi @ShahidaValiSyed04  Can you please check that are you passing the all KEY fields to create a new record?


Hi @Naveen B I have AgreeNbr  as a key field & already passed in Graph


Agreements.Cache.PersistInserted(agreementsNewRecord);

 

I don’t think you ever need to use PersistInserted or any other direct persist methods. Those are very low level and must only be used for some specific cases and when you clearly know what the method does and what’s the expected result is. 

 

Please do always use Save.Press() instead.


Reply