Skip to main content
Solved

Audit columns are getting null value when I hits to save


Forum|alt.badge.img+1

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.

 

Best answer by Dmitrii Naumov

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.

View original
Did this topic help you find an answer to your question?

11 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • February 10, 2022

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 byte[] Tstamp { get; set; }
        public abstract class tstamp : BqlByteArray.Field<tstamp> { }

        #endregion

 


Forum|alt.badge.img+1
Naveen B wrote:

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 byte[] 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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • February 10, 2022

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


 


Forum|alt.badge.img+1
Naveen B wrote:

@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

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • February 10, 2022

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


Forum|alt.badge.img+1
Naveen B wrote:

@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 [Justification]

            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.>

        }


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • February 10, 2022

@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 };
                }
            }
        }

 


Forum|alt.badge.img+1

Hi @Naveen B 

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

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • February 10, 2022

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


Forum|alt.badge.img+1

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


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 632 replies
  • Answer
  • February 10, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings