Wednesday, October 25, 2017

Multiselect lookup in form Datasource fields in AX 2012

// Multi select lookup in form Data source fields in AX 2012

Note: This will not work for Dynamic string control in FORM


Class declaration
SysLookupMultiSelectCtrl    msCtrl;

Init
SysLookupMultiSelectCtrl::construct(element, <control name>, querystr(<queryName>));

Properties
string control auto declaration property set to Yes

SysLookupMultiSelectCtrl class
Method -> Init
//Function
boolean isOnGrid(FormStringControl _ctrl)
    {
        FormControl     parentControl;
        FormControl     currentControl;
        boolean         retValue;
        currentControl  = _ctrl;
        retValue        = false;
        while(currentControl.parentControl() && !retValue)
        {
            parentControl = currentControl.parentControl();
            if(parentControl is FormGridControl)
                retValue = true;
            else
                currentControl = currentControl.parentControl();
        }
        return retValue;
    }
;
     if(isOnGrid(fsCtrlNames))
    {
        fsCtrlNames.registerOverrideMethod('modified', 'ctrlNames_textChange', this);
    }
    else
    {
        fsCtrlNames.registerOverrideMethod('textChange', 'ctrlNames_textChange', this);
    }

Method -> ctrlNames_textChange
 FormDataSource      fds;
    Common              anyBuffer;
    _fsCtrlNames.text(fsCtrlNamesTmp.text());
    fds = _fsCtrlNames.dataSourceObject();
    if(fds)
    {
        anyBuffer = fds.cursor();
        anyBuffer.(_fsCtrlNames.dataField()) = fsCtrlNamesTmp.text();
        fds.refresh();
    }
    fsCtrlNames.modified();


Other Reference: https://krishhdax.blogspot.in/2015/06/editable-multi-select-lookup-in-grid.html

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...