Sometimes we want to open a form from another form with the selected record . For this we need to pass the parameters from form A to form B . This could be achieved by using args class by overriding the click method of button on form A.
In this example we will use two forms form A is salesLine form and form B is inventenquiry form. when the user will click on the button on form A it will open form B filtering the record according the form A value.lets start
- Put a button on form A and override its click method
- write the following code
void clicked()
{
//super();
Args args=new Args();
Itemid itemid;
FormRun formRun;
;
args.name(formstr(InventEnquiry)); // invent enquiry is the form B
args.parm(salesLine.ItemId);// passing the item id from Form A
formRun = classFactory.formRunClass(args); /// passing the args class
formRun.init();
formRun.run();
formRun.wait();
}
3.Now override the init method of the form B data source inventTable
public void init()
{
super();
if(element.args().parm())
{
this.query().dataSourceName('InventTable').addRange(fieldnum(InventTable,ItemId)).value(element.args().parm());
this.query().userUpdate(false);
this.query().interactive(false);
}
}
Hope it helps
cheers,
No comments:
Post a Comment