Skip to main content
Solved

Change default branch in popup dialog, but OrgBAccountID field managed by OrganizationTree attribute


martinxfe
Jr Varsity II
Forum|alt.badge.img

I’m trying to set the Company/Branch field of the Load Options(Load Documents) dialog from the Payments and Applications screen to default to the whole organization as opposed to a specific branch.

However, the field is configured with the OrganizationTree attribute, which doesn’t have an obvious way of overwriting the default.

Since this field resolves to a the Baccount of the branch or organization, I tried appending PXDefault(1), but no dice.

Anyone deal with this before?

 

Best answer by darylbowman

  1.  PXDefault by itself may not do it, because it probably is receiving a default value elsewhere
  2. The new value must be a BAccountID from the Organization table
martinxfe wrote:

Anyone deal with this before?

No, but I was curious.

Try this, replacing “CAP” with your Company CD as a string:

public class Test : PXGraphExtension<ARPaymentEntry>
{
	protected virtual void _(Events.FieldDefaulting<ARPaymentEntry.LoadOptions, ARPaymentEntry.LoadOptions.orgBAccountID> e, PXFieldDefaulting b)
	{
        ARPaymentEntry.LoadOptions row = e.Row;
		if (row is null) return;

		b?.Invoke(e.Cache, e.Args);

		Organization org = SelectFrom<Organization>.
			Where<Organization.organizationCD.StartsWith<P.AsString>>.
            View.Select(e.Cache.Graph, "CAP");

		if (org is object)
		{
			e.NewValue = org.BAccountID;
			e.Cancel = true;
		}
    }
}

 

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

2 replies

darylbowman
Captain II
Forum|alt.badge.img+13
  • 1608 replies
  • Answer
  • June 26, 2024
  1.  PXDefault by itself may not do it, because it probably is receiving a default value elsewhere
  2. The new value must be a BAccountID from the Organization table
martinxfe wrote:

Anyone deal with this before?

No, but I was curious.

Try this, replacing “CAP” with your Company CD as a string:

public class Test : PXGraphExtension<ARPaymentEntry>
{
	protected virtual void _(Events.FieldDefaulting<ARPaymentEntry.LoadOptions, ARPaymentEntry.LoadOptions.orgBAccountID> e, PXFieldDefaulting b)
	{
        ARPaymentEntry.LoadOptions row = e.Row;
		if (row is null) return;

		b?.Invoke(e.Cache, e.Args);

		Organization org = SelectFrom<Organization>.
			Where<Organization.organizationCD.StartsWith<P.AsString>>.
            View.Select(e.Cache.Graph, "CAP");

		if (org is object)
		{
			e.NewValue = org.BAccountID;
			e.Cancel = true;
		}
    }
}

 


martinxfe
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 22 replies
  • June 26, 2024

One might be tempted to wish for a default or branch bypass parameter to be built in to one such OrganizationTreeAttribute.

All the same: That did it!

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