Tasked with hiding a specific field on the salesLine table in the sales order forms depending on the value of a field on SalesTable I searched for methods and came across:
https://community.dynamics.com/ax/f/33/t/168729
I agree with the method of finding the field on the datasource of the formpart
however a better method of making the field invisible is to reference
formDataSource.object(fieldnum(,)).visible(true/false);
instead of actually having to reference the form control.
This will make the field visible/invisble anywhere in the form that the field of the datasource is used.
In my case it was done like this:
private void toggleintraCodeReturn()
{
PartList pl;
int pCount,partdsCount;
FormRun part;
boolean shown;
FormDataSource pfds;
FormDataSource fds,partfds;
shown = this.currentSalesTable().CustMaterial == NoYes::Yes;
if (this.currentSalesTable().isFormDataSource())
{
fds = this.currentSalesTable().dataSource();
pl = new PartList(fds.formRun());
if (pl)
{
// Getting parts for form
for(pCount=1;pCount<=pl.partCount();pCount++)
{
part = pl.getPartById(pCount);
if (part.name() == identifierStr('SalesTableListPagePreviewPane'))
{
// Getting datasources for part form
for(partdsCount=1;partdsCount<=part.dataSourceCount();partdsCount++)
{
fds = part.dataSource(partdsCount);
// Here we got hold of sales lines data source
if (fds.table() == tableNum(SalesLine))
{
fds.object(fieldNum(SalesLine,IntraCodeReturn)).visible(shown);
}
}
}
}
}
}
}
https://community.dynamics.com/ax/f/33/t/168729
I agree with the method of finding the field on the datasource of the formpart
however a better method of making the field invisible is to reference
formDataSource.object(fieldnum(
instead of actually having to reference the form control.
This will make the field visible/invisble anywhere in the form that the field of the datasource is used.
In my case it was done like this:
private void toggleintraCodeReturn()
{
PartList pl;
int pCount,partdsCount;
FormRun part;
boolean shown;
FormDataSource pfds;
FormDataSource fds,partfds;
shown = this.currentSalesTable().CustMaterial == NoYes::Yes;
if (this.currentSalesTable().isFormDataSource())
{
fds = this.currentSalesTable().dataSource();
pl = new PartList(fds.formRun());
if (pl)
{
// Getting parts for form
for(pCount=1;pCount<=pl.partCount();pCount++)
{
part = pl.getPartById(pCount);
if (part.name() == identifierStr('SalesTableListPagePreviewPane'))
{
// Getting datasources for part form
for(partdsCount=1;partdsCount<=part.dataSourceCount();partdsCount++)
{
fds = part.dataSource(partdsCount);
// Here we got hold of sales lines data source
if (fds.table() == tableNum(SalesLine))
{
fds.object(fieldNum(SalesLine,IntraCodeReturn)).visible(shown);
}
}
}
}
}
}
}
Comments
Post a Comment