Skip to main content
Solved

Make Compulsory / Required

  • September 8, 2021
  • 3 replies
  • 423 views

pandachan48
Jr Varsity II
Forum|alt.badge.img

How to make it compulsory / Required when user create customer account, I want to make it cannot save if the line is empty.  

 

 

 

and Also how to make the column compulsory / Required in SO line
 

 

Best answer by Naveen Boga

Hi @pandachan48   As suggested by @markusray17 It requires a small piece of customization.

Please find the code below.

// Sales Orders screen Customization 


public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
    {
        #region SalesPersonID
        [PXMergeAttributes(Method = MergeMethod.Append)]
        [PXRemoveBaseAttribute(typeof(PXDefaultAttribute))]
        [PXDefault(typeof(SOOrder.salesPersonID), PersistingCheck = PXPersistingCheck.NullOrBlank)]
        protected virtual void SOLine_SalesPersonID_CacheAttached(PXCache cache)
        {
        }
        #endregion 
    }

// Customers screen Customization

    public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
    {
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(PersistDelegate del)
        {
            if (Base.SalesPersons.Select().FirstTableItems.ToList().Count == 0)
            {
                throw new PXException("Salesperson info not found");
            }
            del();
        }
    }

 

 

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

3 replies

Forum|alt.badge.img+5
  • Jr Varsity II
  • 237 replies
  • September 30, 2021

This would be a customization.

You can use an event handler for RowPersisting to check if there is at least one salesperson listed and throw an error if their is not.

[PXDefault(typeof(SOOrder.salesPersonID), PersistingCheck = PXPersistingCheck.Nothing)]

For the SOLine you can just modify the PXDefault Attribute to set the PXPersitingCheck to NullOrBlank which will make it a required field.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3398 replies
  • Answer
  • October 1, 2021

Hi @pandachan48   As suggested by @markusray17 It requires a small piece of customization.

Please find the code below.

// Sales Orders screen Customization 


public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
    {
        #region SalesPersonID
        [PXMergeAttributes(Method = MergeMethod.Append)]
        [PXRemoveBaseAttribute(typeof(PXDefaultAttribute))]
        [PXDefault(typeof(SOOrder.salesPersonID), PersistingCheck = PXPersistingCheck.NullOrBlank)]
        protected virtual void SOLine_SalesPersonID_CacheAttached(PXCache cache)
        {
        }
        #endregion 
    }

// Customers screen Customization

    public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
    {
        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(PersistDelegate del)
        {
            if (Base.SalesPersons.Select().FirstTableItems.ToList().Count == 0)
            {
                throw new PXException("Salesperson info not found");
            }
            del();
        }
    }

 

 


Forum|alt.badge.img
  • Freshman I
  • 23 replies
  • February 3, 2024

I tried using this and got the following error.  Should work for 2023r2?

 

[2024-02-03 20:44:58.989] \App_RuntimeCode\salesperson01.cs(6): error CS0246: The type or namespace name 'CustomerMaint' could not be found (are you missing a using directive or an assembly reference?)
[2024-02-03 20:44:58.989] \App_RuntimeCode\salesperson01.cs(6): error CS0246: The type or namespace name 'CustomerMaint' could not be found (are you missing a using directive or an assembly reference?)

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