Skip to main content

Workaround to manage "Notes" & "Files" Actions


aaghaei
Captain II
Forum|alt.badge.img+10

Hello Community,

I decided to post the below as I saw quite a few questions about managing the “Notes” & “Files” action buttons on the forms and how to prevent changes based on some conditions but couldn’t really see a solution or workaround that can benefit others. The below workaround is not so great but does the work. 

 

Notes: In the below example, I am reverting the changes made to the “Notes” of the Sales Orders which are not On Hold, Pending Approval, or Pending Processing. Disabling the “Notes” most of the time is not really work because people need to read the comments but at the same time, you do not want to change. I didn’t spend lots of time on it but couldn’t find an easy way to disable cache modification or the OK button of the Note dialog so instead, I am reverting the changes made on SOs which are not in the above-mentioned statuses. Users can make changes but it won’t be saved and when the page is “Refreshed” or closed or navigated to another document the original note will be displayed anyways. Not great but OK.

 

Files: As for the files, apparently Acumatica initializes the “WikiFileMaintenance” graph. For the same SO statuses, I am making the action buttons invisible so the user won’t be able to alter the existing attachments. The good news is you can develop the customization for all screens “Files” action button monitoring in this graph.

 

I just am performing simple validations and disabling the “Files” associated actions or reverting the changes made to the “Notes”. But, based on your use case you can develop more complicated conditions. For example, you may want to check if a user is a part of the “Admin” group and then avoid this restriction.

 

Any suggestion to improve and enhance this code is welcome.

 

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.SM;
using PX.Objects.SO;

namespace HCL
{
    // Ignore changes made to the "Notes" and revert to the original
    public class HCLSOOrderEntryExt : PXGraphExtension<SOOrderEntry>
    {
        public static bool IsActive() => true;

        //**************************************** Persist ****************************************//
        #region Persist
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(PersistDelegate baseMethod)
        {
            if (Base.Document.Current != null)
            {
                var status = Base.Document.Current.Status;

                if (status != SOOrderStatus.Hold && status != SOOrderStatus.PendingApproval && status != SOOrderStatus.PendingProcessing)
                {
                    Base.Caches[typeof(Note)].Clear();
                }
            }

            baseMethod?.Invoke();
        }
        #endregion
    }

    // Prevent changing the existing "Files"
    public class HCLSMWikiFileMaintenanceExt : PXGraphExtension<WikiFileMaintenance>
    {
        public static bool IsActive() => true;

        //**************************************** Event Handlers ****************************************//
        #region UploadFileWithIDSelector RowSelected
        protected void _(Events.RowSelected<UploadFileWithIDSelector> e)
        {
            var isVisible = true;

            if (e.Row != null)
            {
                // Sales Order
                SOOrder salesOrder = SelectFrom<SOOrder>
                    .InnerJoin<NoteDoc>.On<SOOrder.noteID.IsEqual<NoteDoc.noteID>>
                    .Where<NoteDoc.fileID.IsEqual<@P.AsGuid>>
                    .View.ReadOnly.SelectWindowed(e.Cache.Graph, 0, 1, e.Row.FileID);

                if (salesOrder != null)
                {
                    var status = salesOrder.Status;
                    if (status != SOOrderStatus.Hold && status != SOOrderStatus.PendingApproval && status != SOOrderStatus.PendingProcessing)
                    {
                        isVisible = false;
                    }
                }

                // Develop Other Objects Logics & Set the Visibility Status
            }

            Base.Actions["save"].SetVisible(isVisible);
            Base.Actions["delete"].SetVisible(isVisible);
            Base.Actions["cancel"].SetVisible(isVisible);
            Base.Actions["checkOut"].SetVisible(isVisible);
            Base.Actions["undoCheckOut"].SetVisible(isVisible);
            Base.Actions["uploadFile"].SetVisible(isVisible);
            Base.Actions["uploadNewVersion"].SetVisible(isVisible);
        }
        #endregion
    }
}

 

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

3 replies

Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2756 replies
  • March 7, 2023

Thank you for sharing this with the community @aaghaei !


Forum|alt.badge.img
  • Freshman II
  • 35 replies
  • March 19, 2023

Hi @aaghaei . I try Ignore changes made to the "Notes" and revert to the original for SoShipment screen.

namespace PX.Objects.SO {     public class SOShipmentEntry_Extension : PXGraphExtension<PX.Objects.SO.SOShipmentEntry>     {         public static bool IsActive() => true;         //**************************************** Persist ****************************************//         #region Persist         public delegate void PersistDelegate();         [PXOverride]         public void Persist(PersistDelegate baseMethod)         {             if (Base.Document.Current != null)             {                 var status = Base.Document.Current.Status;

                if (status != SOOrderStatus.Hold && status != SOOrderStatus.PendingApproval && status != SOOrderStatus.PendingProcessing)                 {                     Base.Caches[typeof(Note)].Clear();                 }             }

            baseMethod?.Invoke();         }         #endregion

}

}

I add break point at line 56, but it not active break point, in the screen, i until change notes as usual. Can you help me?


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1203 replies
  • March 19, 2023

I didn’t see any break points but if you add BP but is not hit in VS I can say either your project is not bound to your instance or you are not complied the latest changes. Also try to close your browser and VS and rerun. I can not think of other common causes 


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