Skip to main content
Solved

Make the Override Contact Checkbox ticked by default

  • September 26, 2023
  • 5 replies
  • 199 views

Forum|alt.badge.img

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?

 

 

 

Best answer by jinin

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

        }
 

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

5 replies

Forum|alt.badge.img+9
  • Semi-Pro III
  • 229 replies
  • September 26, 2023

Hi @LungileNjakazi37 ,

Could you please try below code snippet?

[PXDefault(PersistingCheck = PXPersistingCheck.NullOrBlank)]

Hope, it helps!

Regards,

Sweta


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3409 replies
  • September 26, 2023

@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)
            {
            }
        }

 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 701 replies
  • Answer
  • September 26, 2023

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

        }
 


RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 253 replies
  • September 26, 2023

@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.

 


Forum|alt.badge.img

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


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