1

I am using D365FO (update 28). There is need for filtering based on the responsible person on custom created workspace. Table PMCContract contains HCMWORKERRECID column. Filter is opening correctly list of persons but regardless of which person is chosen. Also, when workspace loaded , by default it's always loaded first person in list, but it should be empty.

    [Form]
public class PMCContractManagementWorkspace extends FormRun implements SysIFilterProvider
{

    SysFilterChangeEvent changeEvent;

    public void close()
    {
        super();

        SysFilterLastValueHelper::saveLastValue(worker);
    }

    public void initParmDefault()
    {
        if (!Worker.value())
        {
            HcmWorker     hcmWorker;
            PMCContract personUser;

            select firstonly RecId from hcmWorker
                exists join personUser
                where hcmWorker.RecId == personUser.HCMWORKERRECID;
                && personUser.HCMWORKERRECID == curUserId();

            Worker.value(hcmWorker.recId);
        }
    }

    public void init()
    {
        super();

        SysFilterLastValueHelper::getLastValue(worker);

        changeEvent = SysFilterChangeEvent::newFromFormControl(worker);

        this.initParmDefault();
    }

    public SysIFilter parmFilter()
    {
        SysIFilter                      filter = SysFilterFactory::createEmptyFilter();
        UserInfo                        currentUser;
        HcmWorker                       hcmWorker;
        PMCContract                     personUser;
        SysFilterValueResolutionMethod  filterValueResolutionMethod = SysFilterValueResolutionMethod::All;

        select HCMWORKERRECID from personUser
            //exists join hcmWorker
            where hcmWorker.RecId == personUser.HCMWORKERRECID;
                    //&& hcmWorker.RecId == Worker.value();

        SysIFilterValue  filterValue = SysFilterValueFactory::createFilterValueForBuffer(currentuser);

        if (currentUser)
        {
            filterValueResolutionMethod = SysFilterValueResolutionMethod::None;
        }

        filter.addItem(filterValue, SysFilterOperator::Equal, filterValueResolutionMethod);

        return filter;
    }

    public SysFilterChangeEvent parmChangeEvent()
    {
        return changeEvent;
    }

}
DarthCSharper
  • 133
  • 1
  • 13
  • The logic in the `parmFilter` method looks odd. It selects from `personUser` and adds a criteria on `hcmWorker.RecId`, but `hcmWorker` is not joined in the statement. But then it does not use `personUser`. Instead, `currentUser` is used, which does not seem to be initialized. Could you add some comments in the code that explain what you think the code is doing? – FH-Inway Sep 14 '19 at 09:18
  • I used logic from SalesOrderProcessing workspace. I need to filter all data on workspace base on responsible person, in this case (hcmworkerrecId). – DarthCSharper Sep 16 '19 at 12:21

0 Answers0