torsdag den 6. oktober 2016

Toggling visibility of fields in a Grid in then preview Pane of a ListPage form using code

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:

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


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
                part = pl.getPartById(pCount);
                if ( == identifierStr('SalesTableListPagePreviewPane'))
                    // Getting datasources for part form
                        fds = part.dataSource(partdsCount);
                        // Here we got hold of sales lines data source
                        if (fds.table() == tableNum(SalesLine))

Ingen kommentarer:

Send en kommentar