Skip to main content
Answer

Make the Override Contact Checkbox ticked by default

  • September 26, 2023
  • 5 replies
  • 227 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);
            }

        }
 

5 replies

Forum|alt.badge.img+9
  • Semi-Pro III
  • 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
  • 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
  • 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
  • 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.