Solved

Make the Override Contact Checkbox ticked by default

  • 26 September 2023
  • 5 replies
  • 149 views

Userlevel 2
Badge

Hi Everyone.

 

I am trying to make a checkbox required but I am having some trouble.

 

I tried updating the attributes by adding PXDefault(true) and [PXUnboundDefault(true)]but that didn’t make the checkbox default to checked. I looked at this article but still no luck.

 

What else can I try?

 

 

 

icon

Best answer by jinin 26 September 2023, 18:44

View original

5 replies

Userlevel 7
Badge +10

Hi @LungileNjakazi37 ,

Could you please try below code snippet?

[PXDefault(PersistingCheck = PXPersistingCheck.NullOrBlank)]

Hope, it helps!

Regards,

Sweta

Userlevel 7
Badge +17

@LungileNjakazi37 Can you please try with the below code ?

 

   public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXRemoveBaseAttribute(typeof(PXDefaultAttribute))]
[PXDefault(true, PersistingCheck = PXPersistingCheck.Nothing)]
protected virtual void SOBillingContact_IsDefaultContact_CacheAttached(PXCache cache)
{
}
}

 

Userlevel 7
Badge +11

HI @LungileNjakazi37,

If we assign the PXDefault or PXDefaulting event for the override contact field, it doesn't work. However, we can write the code in the Customer Field Updated event, and it works.

Please refer to the code snippet below:

protected void SOOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = (SOOrder)e.Row;

            if (Base.Billing_Contact.Select().FirstOrDefault() != null)
            {
                Base.Billing_Contact.Current = Base.Billing_Contact.Select().FirstOrDefault();
                Base.Billing_Contact.Current.OverrideContact = true;
                Base.Billing_Contact.Update(Base.Billing_Contact.Current);
            }

        }
 

Userlevel 7
Badge +4

@LungileNjakazi37  have you had a chance to review @Naveen Boga ‘s blog post:

Tips & Tricks Using Acumatica's Low-Code/No-Code | Acumatica Cloud ERP

here’s a relevant snip:

Make A Field Mandatory

Previously, we used the PXDefault attribute to make a field mandatory. But in the Customization Project Editor, we can use the settings to make the field mandatory.

  1. From the Customization Project Editor, select Fields in the left-hand menu.
  2. Set the Required section to True.
  3. Publish the Customization Package to save the change.

 

Userlevel 2
Badge

Thank you all for the suggestions. @jinin your method worked for me. Thank you.

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