Skip to main content
Solved

Save and Close button

  • July 8, 2021
  • 1 reply
  • 721 views

Can we change the function of the Save and Close button?

If yes, How can we change it?

Best answer by Hughes Beausejour

Create a graph extension and re-define the ‘Save & Close’ action in it.

Example that extends Save & Close action for Activity screen:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.ObjectsExt.CR;
using SP.Objects.SP;
using Tools.DAC;

namespace SP.ObjectsExt.SP
{
    public class SPCommentExt : PXGraphExtension<SPComment>
    {
        public override void Initialize()
        {
            ObjectsExt.CheckReattestRequired.Check(this.Base);
        }

        public PXAction<CRActivity> SaveClose;
        [PXUIField(DisplayName = "Save & Close")]
        [PXButton]
        public virtual IEnumerable saveClose(PXAdapter pxAdapter)
        {
            foreach (var res in Base.SaveClose.Press(pxAdapter))
            {
            }
            if (PXSiteMap.Provider.FindSiteMapNodeByScreenID(Base.Comment.Current.LastModifiedByScreenID)
                    .GraphType.IndexOf("Case") > -1)
            {
                if (Base.Case.Current.Status != CRCaseStatusesAttribute._PENDING_CUSTOMER)
                {
                    CRCaseExtension rowExt = Base.Caches[typeof(CRCase)].GetExtension<CRCaseExtension>(Base.Case.Current);
                    if (rowExt == null) return pxAdapter.Get();
                    if (rowExt.UsrReminderCount.HasValue)
                    {
                        rowExt.UsrReminderCount = null;
                    }
                    if (Base.Caches[typeof(CRCase)].GetStatus(Base.Case.Current) == PXEntryStatus.Notchanged)
                        Base.Caches[typeof(CRCase)].SetStatus(Base.Case.Current, PXEntryStatus.Updated);
                }
                Base.Actions.PressSave();
            }
            return pxAdapter.Get();
        }
    }
}

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

1 reply

Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • Answer
  • July 8, 2021

Create a graph extension and re-define the ‘Save & Close’ action in it.

Example that extends Save & Close action for Activity screen:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.ObjectsExt.CR;
using SP.Objects.SP;
using Tools.DAC;

namespace SP.ObjectsExt.SP
{
    public class SPCommentExt : PXGraphExtension<SPComment>
    {
        public override void Initialize()
        {
            ObjectsExt.CheckReattestRequired.Check(this.Base);
        }

        public PXAction<CRActivity> SaveClose;
        [PXUIField(DisplayName = "Save & Close")]
        [PXButton]
        public virtual IEnumerable saveClose(PXAdapter pxAdapter)
        {
            foreach (var res in Base.SaveClose.Press(pxAdapter))
            {
            }
            if (PXSiteMap.Provider.FindSiteMapNodeByScreenID(Base.Comment.Current.LastModifiedByScreenID)
                    .GraphType.IndexOf("Case") > -1)
            {
                if (Base.Case.Current.Status != CRCaseStatusesAttribute._PENDING_CUSTOMER)
                {
                    CRCaseExtension rowExt = Base.Caches[typeof(CRCase)].GetExtension<CRCaseExtension>(Base.Case.Current);
                    if (rowExt == null) return pxAdapter.Get();
                    if (rowExt.UsrReminderCount.HasValue)
                    {
                        rowExt.UsrReminderCount = null;
                    }
                    if (Base.Caches[typeof(CRCase)].GetStatus(Base.Case.Current) == PXEntryStatus.Notchanged)
                        Base.Caches[typeof(CRCase)].SetStatus(Base.Case.Current, PXEntryStatus.Updated);
                }
                Base.Actions.PressSave();
            }
            return pxAdapter.Get();
        }
    }
}


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