Tuesday, January 16, 2024

User multiselect lookup on UI Builder class

class UpdateEndOfLifeOnItemsUIBuilder_Custom extends SysOperationAutomaticUIBuilder
{
    UpdateEndOfLifeOnItemsContract_Custom contract;
    DialogField                         usersDF;

    public void postBuild()
    {
        super();
        contract    = this.dataContractObject() as UpdateEndOfLifeOnItemsContract_Custom;
        usersDF	    = this.bindInfo().getDialogField(contract, methodStr(UpdateEndOfLifeOnItemsContract_Custom, parmUsers));
        usersDF.lookupButton(FormLookupButton::Always);
    }

    public void postRun()
    {
        super();
        this.lookupUsr();
    }

    /// <summary>
    /// Creates a multi-select users lookup dialog box field
    /// </summary>
    public void lookupUsr()
    {
        Query		            query		    = new Query();
        QueryBuildDataSource    qbdsLegalEntity = query.addDataSource(tableNum(UserInfo));

        qbdsLegalEntity.fields().addField(fieldNum(UserInfo, id));
        qbdsLegalEntity.fields().addField(fieldNum(UserInfo, Name));
        container selectedFields = [tableNum(UserInfo), fieldNum(UserInfo, id)];
        SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), usersDF.control(), query, false, selectedFields);
    }
	
	 /// <summary>
    /// Gets or sets the value of the datacontract parameter users.
    /// </summary>
    /// <param name="_users">
    /// The new value of the datacontract parameter users; optional.
    /// </param>
    /// <returns>
    ///  The current value of datacontract parameter users
    /// </returns>
    [
        DataMemberAttribute,
        SysOperationLabelAttribute(literalStr("@SYS25412")),
        SysOperationDisplayOrderAttribute("2")
    ]
    public str parmUsers(str _users = users)
    {
        users = _users;
        return users;
    }

}

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8