Skip to main content
Solved

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

  • 26 June 2024
  • 2 replies
  • 27 views

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?

 

2 replies

Badge +12
  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

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

 

Userlevel 3
Badge

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