Skip to main content

Hi All

Do you have any idea of below functionality could you please suggest me on this. I hope your support & Presence 

Thanks in Advance.

Here is my Revision button code

 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);

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.Update(agreementsNewRecord);
this.Actions.PressSave();
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);

}

 

Hi @ShahidaValiSyed04 

Can you please try the code like below? I didn't test, but hope this will work

Sample code:

  if (result == WebDialogResult.OK)
            {
                if (Agreements.Current != null)
                {
                    SSPAgreement agreementsOldRecord = Agreements.Current;

                    AgreementGraph graph = CreateInstance<AgreementGraph>();
                     
                     SSPAgreement agreementsNewRecord = new SSPAgreement()
                    {
                        TemplateCode = agreementsOldRecord.TemplateCode,
                        Revision = (int)(agreementsOldRecord.Revision + 1),
                        AgreeNbr = (string)(agreementsOldRecord.AgreeNbr),
                        Active = agreementsOldRecord.Active,
                    };

                    graph.Agreements.Cache.Insert(agreementsNewRecord);
                    graph.Actions.PressSave();
                    
                    throw new PXRedirectRequiredException(graph, "Agreements") { Mode = PXBaseRedirectException.WindowMode.Same };

 


There is actually PX.Objects.AM.PXRevisionableGraph that you can use to implement Revisions functionality similar to what we have in Acumatica without a need to define the standard actions and behavior.


Reply