Solved

Do you have any Idea of this Button functionality ?

  • 10 February 2022
  • 2 replies
  • 115 views

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

}

 

icon

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

View original

2 replies

Userlevel 7
Badge +5

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.

Userlevel 7
Badge +11

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

 

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