Dynamically create a form and define the link type relation between Form datasource Tables

Actually my requirement is to create a form using a job and when selecting a Sales Order, corresponding Sales lines should refresh in the below grid …
Can you please suggest how to build an linktype relation ( active or delayed ) in the job?
formDatasource = formRun.dataSource(1);//SalesTable
formDatasource1 = formRun.dataSource(2);//SalesLine

formDataSource1.linkType(FormLinkType::Delayed);
Is that not working?

Why exactly do you want complicate your life and waste your time? You can achieve the same thing using the designer in a fraction of time that you would need to write all the code by hand. You seem to already know how the form should look like, so you can do it at design-time.

Anyway, such datasource must a link, and it should be the delayed link for performance reasons. AX already contains such a form with sales orders and lines (called SalesTable), so you always look there if in doubt.

Yeah actually I know that form but i Have to achieve that through code…

you need to add join source and set data source in grid controls.

formBuildDatasource1.joinSource(formBuildDatasource.name());
//formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, ‘Tab’);
//formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, ‘TabPage’);
formBuildGridControl = formBuildDesign.addControl(FormControlType::Grid, ‘Grid’);
formBuildGridControl.dataSource(formBuildDatasource.name());
formBuildGridControl1 = formBuildDesign.addControl(FormControlType::Grid, ‘Grid’);
formBuildGridControl1.dataSource(formBuildDatasource1.name());

Hey actually I didnt use joinsource
formbuilddatasource.joinsource(tableStr(SalesLine));
formDataSource1.linkType(FormLinkType::Delayed);
This helped me a lot…