Skip to main content
Solved

Make the Override Contact Checkbox ticked by default

  • Sep 26, 2023 11:30 AM UTC
  • 5 replies
  • 290 views
  • Translate All

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

5 replies

Forum|alt.badge.img+9
  • Semi-Pro III
  • Sep 26, 2023 11:35 AM UTC

Hi @LungileNjakazi37 ,

Could you please try below code snippet?

[PXDefault(PersistingCheck = PXPersistingCheck.NullOrBlank)]

Hope, it helps!

Regards,

Sweta

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Sep 26, 2023 11:58 AM UTC

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

 

Translate

jinin
Pro I
Forum|alt.badge.img+12
  • Pro I
  • Answer
  • Sep 26, 2023 4:44 PM UTC

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

        }
 

Translate

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+5
  • Acumatica Moderator
  • Sep 26, 2023 7:07 PM UTC

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

 

Translate

Forum|alt.badge.img

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

Translate