Announcements
I have an extension class on form ReqTransPo.
I need to on initialized reference the method InventDimSetupObject().
[FormEventHandler(formStr(ReqTransPo), FormEventType::Initialized)]
public void ReqTransPo_OnInitialized(xFormRun sender, FormEventArgs e)
{
showStorageDimensionColumns = NoYes::Yes;
InventDimParm InventDimParmLocal = sender.inventDimSetupObject().inventDimSetupObject.parmDimParmVisibleGrid();
InventDimParmLocal.InventLocationIdFlag = true;
InventDimParmLocal.InventSiteIdFlag = true;
}
However I get the error: Class 'xFormRun' does not contain a definition for method 'inventDimSetupObject'.
This method is under the form methods and it is not defined as private or protected, which in both cases won't allow me to access it in an extension.
So how do I get ahold of it? I need to load the form with the inventory dimension InventLocationId and InvetnSiteId visible in the grid by default. The user doesn't want to every time they go into this form to have to click on view > Display > Dimensions and select warehouse and site.
Any suggestions are much appreciated.
Thank you Sukrut and Nikolaos
I tried your suggestions before and it didn't work.
However when I tried it again I noticed I had a typo:
inventDimSetupObject().inventDimSetupObject.parmDimParmVisibleGrid();
should have been: inventDimSetupObject().parmDimParmVisibleGrid();
I also had to move it to the OnPostRun event because the class in InvntDimSetupObject() was still empty OnInitialized .
[FormEventHandler(formStr(ReqTransPo), FormEventType::PostRun)]
public void ReqTransPo_OnPostRun(xFormRun sender, FormEventArgs e)
{
FormRun callerForm = sender as FormRun;
InventDimParm InventDimParmLocal = callerForm.inventDimSetupObject().parmDimParmVisibleGrid();
InventDimParmLocal.InventLocationIdFlag = true;
InventDimParmLocal.InventSiteIdFlag = true;
InventDimParmLocal.WMSLocationIdFlag = false;
InventDimParmLocal.LicensePlateFlag = false;
}
Thanks for your help.
Cast the sender variable to a variable of type FormRun:
FormRun callerForm = sender as FormRun;
callerForm.myMethod();
Did you try this
FormRun form = sender.formRun();
DirPartyLookupEntitiesFilter dirPartyLookupEntitiesFilter = form.getDirPartyLookupEntitiesFilter();
You can find plenty of examples in Application explorer . This example is from class DirPartyLookupFormEventHandler which is handler class for DirPartyLookup form.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,142 Super User 2024 Season 2
Martin Dráb 227,979 Super User 2024 Season 2
nmaenpaa 101,148