Skip to main content

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

If yes, How can we change it?

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;
        yPXUIField(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.CachesCtypeof(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