Reputation: 1
I want to dynamically change the warehouse selector results in Acumatica on the following screens:
, by either company(All warehouse under selected company) or branch. The condition will be met with custom fields I have added to the Inventory preferences screen.
I came to the conclusion of having to use a custom selector attribute, but how to achieve this I am not sure.
Any guidance and help would be greatly appreciated.
See code attached for my Custom DAC fields and the code for the Sales Order Graph:
public class INSetupExt : PXCacheExtension<PX.Objects.IN.INSetup>
{
#region UsrAllowBlockin
[PXDBBool]
[PXDefault(false)]
[PXUIField(DisplayName="Block Normal Journal Posting by Creator")]
public virtual bool? UsrAllowBlockin { get; set; }
public abstract class usrAllowBlockin : PX.Data.BQL.BqlBool.Field<usrAllowBlockin> { }
#endregion
#region UsrByCompany
[PXDBBool]
[PXDefault(true)]
[PXUIField(DisplayName="By Company")]
[PXUIEnabled(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
[PXUIVisible(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
public virtual bool? UsrByCompany { get; set; }
public abstract class usrByCompany : PX.Data.BQL.BqlBool.Field<usrByCompany> { }
#endregion
#region UsrByBranch
[PXDBBool]
[PXDefault(false)]
[PXUIField(DisplayName="By Branch")]
[PXUIEnabled(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
[PXUIVisible(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
public virtual bool? UsrByBranch { get; set; }
public abstract class usrByBranch : PX.Data.BQL.BqlBool.Field<usrByBranch> { }
#endregion
}
protected void SOLine_BranchID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOLine)e.Row;
INSetupExt extINSetup = Base.insetup.SelectSingle().GetExtension<INSetupExt>();
if (row != null)
{
//retrieve current branch
int? currentSelectedBranch = Base.Document.Current?.BranchID;
int currentSelectedCompany = PX.Data.Update.PXInstanceHelper.CurrentCompany;
//See what condition is selected
//If filter by branch is selected, based on the branch selected in the financial tab,
//allow selection of all warehouses linked the transaction branch only
//Else if filter by company is selected,
//allow selection of all warehouses linked to the company or branches within the company associated with the document branch.
if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByBranch == true)
{
}
else if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByCompany == true)
{
}
}
}
Upvotes: 0
Views: 243
Reputation: 771
I would add a custom unbound field on soLine (as an int? usrSiteEntityID) that is set by your field updated (be sure to default it), and then override the SiteID selector as follows (this is a very rough example):
Search INSite.siteId where INSite.branch equal usrSiteEntityID or INSite.company equal usrSiteEntityID
then you can do it with a simple selector
Upvotes: 1