Filtering Warehouse lookup based on SiteID lookup selection

I have written a run base method for site and warehouse functionality to achieve two tasks :

  1. To make the warehouse field lookup visible when a checkbox (Visible) is removed from check.

  2. To filter the warehouse lookup based on the selection of site id.

I wrote the following code as :

public void Fld3_1_modified()
{
FormStringcontrol control = dialog.formRun().controlCallingMethod();
boolean isFieldModified;
;

isFieldModified = control.modified();

if(isFieldModified)
{
dlgLocationId.visible(false);
}
this.dialogUpdate();
}
//The above code only works for once and makes the field invisible and the checkbox which i enabled remains enabled even if i try to change it.

void Fld3_1_lookup()
{
FormStringcontrol control = dialog.formRun().controlCallingMethod();
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventLocation), control);
Query query = new Query();
;
sysTableLookup.addLookupField(fieldNum(InventSite, SiteId));
sysTableLookup.addLookupField(fieldNum(InventLocation, InventLocationId));
if(dlgSiteId.value())
{
query.addDataSource(tableNum(InventLocation)).addRange(fieldNum(InventLocation, InventLocationId)).value(dlgSiteId.value());
}
//You can add the ranges for filtering
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
//The above code has no affect on the lookup fields

I am so much confused about this code

query.addDataSource(tableNum(InventLocation)).addRange(fieldNum(InventLocation, InventLocationId)).value(dlgSiteId.value());

  1. Try to implement your changes on dialogSelectCtrl method.

  2. Have you registered the lookup method for override in dialog?

The range should be on Site

if(dlgSiteId.value())

{
query.addDataSource(tableNum(InventLocation)).addRange(fieldNum(InventLocation, InventSiteId)).value(dlgSiteId.value());

}

My code is not debugging in dialogcontrol() , so i added it in modified method as

public void Fld3_1_modified()

{

FormStringcontrol control = dialog.formRun().controlCallingMethod();

boolean isFieldModified;

;

isFieldModified = control.modified();

if(isFieldModified)

{

dlgLocationId.visible(false);

}

{

dlgLocationId.visible(true);

}

dialog.allowUpdateOnSelectCtrl(True);

}

I know ismodified is not gonna work here as because i can update my runbase form for only once when it is modified. But i need something that will make the field disapper based on the check and uncheck for that what should i do ??

are you calling the dialogSelectCtr() in your dialog method?

yes i am

following is the code which i am using :

public void dialogSelectCtrl()

{

super();

If(dialogChkbox.Value() == false)

{

dlgLocationId.visible(false);

}

else

{

dlgLocationId.visible(true);

}

}

I set the default value of the check box to true my main query is :

  • I cannot change my checkbox value
  • if i do not make it true by default it makes the field which i want to make invisible without clicking on the checkbox i.e( when i click on any other place on the form it makes the field invisble.)

Look at this example,

\Classes\PriceDiscAdmCopy\dialogSelectCtrl

\Classes\PriceDiscAdmCopy\dialog

Not found

My query has been resolved the updated methods are :

void Fld2_1_lookup()

{

;

InventLocation::lookupBySiteIdAllTypes(dlgLocationId.control(),dlgSiteId.value());

}

For the filtering the warehouse values based on the lookup

public void dialogSelectCtrl()

{

boolean ret= true;

;

If(!dialogChkbox.Value())

{

ret = false;

}

dlgLocationId.visible(ret);

super();

}

For making the dialog box invisible on checking/unchecking the checkbox value

You have not told us about your version. The example i mentioned is from AX 2012 R3

Thanks a lot bro , but mine was 2009 its done i am starting a new thread now for another query related to it.