Solved

Make Compulsory / Required

  • 8 September 2021
  • 3 replies
  • 154 views

Userlevel 2
Badge

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
 

 

icon

Best answer by Naveen Boga 1 October 2021, 08:06

View original

3 replies

Userlevel 2
Badge

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?)
Userlevel 7
Badge +17

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

 

 

Userlevel 6
Badge +5

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.

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