Solved

Audit columns are getting null value when I hits to save

  • 10 February 2022
  • 11 replies
  • 297 views

Userlevel 3
Badge +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.

 

icon

Best answer by Dmitrii Naumov 10 February 2022, 17:54

View original

11 replies

Userlevel 7
Badge +17

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

 

Userlevel 3
Badge +1

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

Userlevel 7
Badge +17

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


 

Userlevel 3
Badge +1

@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

 

Userlevel 7
Badge +17

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

Userlevel 3
Badge +1

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

        }

Userlevel 7
Badge +17

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

 

Userlevel 3
Badge +1

Hi @Naveen B 

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

 

Userlevel 7
Badge +17

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

Userlevel 3
Badge +1

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

Userlevel 7
Badge +5

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


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