web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Activity lookup based on Project

(0) ShareShare
ReportReport
Posted on by 182

Hi Experts,

I have a custom form with two columns Project and Activity. My requirement is to add a look up on activity field based on project selected in the project field. I am achieving this by below code

  public void lookup(FormControl _formControl, str _filterStr)
    {
        //super(_formControl, _filterStr);

        HierarchyTreeTable::lookupHierarchyTree(_formControl, ProjTable::find(ANCPettyCashProjJournalLines.ProjId));

                
    }

However this code is displaying the entire activities including closed ones related to the project. What can I do to see only active activities in the lookup? 

I have the same question (0)
  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Two options:

    1. Create a new method in ProjTable similar to find method possibly name it findActiveActivities and return non-closed activities from this method. Refer this method in your lookup

    HierarchyTreeTable::lookupHierarchyTree(_formControl, ProjTable::findActiveActivities(ANCPettyCashProjJournalLines.ProjId));

    2. Create a lookup method at table level using query and return filtered records from that method, later use table lookup method on form control.

  • Maverick Profile Picture
    182 on at

    Hi Faisal, Thanks for your prompt response, but my query is how do I add the query filter to the below code

    HierarchyTreeTable::lookupHierarchyTree(_formControl, ProjTable::findActiveActivities(ANCPettyCashProjJournalLines.ProjId));

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    This uses the form lookup so you need to extend the HierarchyTreeLookup form through an extension class where you can extend the run method of HierarchyTreeLookup form. If you are not a developer then get one :) as you would need one.

    public client static void lookupHierarchyTree(FormStringControl _ctrl, Common _common, NoYes _showChildOnly = NoYes::No)
    {
    Args args;
    FormRun formRun;

    HierarchyIdBase hierarchyId;

    hierarchyId = HierarchyLinkTable::findRefTableRecId(_common.TableId, _common.RecId).HierarchyId;

    args = new Args();
    args.name(formStr(HierarchyTreeLookup));
    args.caller(_ctrl);

    args.record(_common);
    args.parm(hierarchyId);
    args.parmEnum(_showChildOnly);
    args.parmEnumType(enumNum(NoYes));

    formRun = classfactory.formRunClass(args);
    formRun.init();
    _ctrl.performFormLookup(formRun);
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans