Skip to main content
Solved

Do you have any Idea of this Button functionality ?

  • February 10, 2022
  • 2 replies
  • 129 views

Forum|alt.badge.img+1

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

        }

 

Best answer by Dmitrii Naumov

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.

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

2 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 693 replies
  • February 10, 2022

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

 


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

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


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