Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Add condition on ItemId Field lookup in D365FO

(0) ShareShare
ReportReport
Posted on by 100

Hi Experts,

How to add a filter to show particular Item in ItemID field of SalesLine Datasource in SalesTable Form.

I want the condition in lookup that-
It will check the "ProductLifecycleStateId" field in "InventTable" Table. If It is not blank than will go inside to "EcoResProductLifecycleState " Form and check the field -"EngChgEcoResProductLifeCycleStateRule_StateRuleName" has value "Sales order" & if Field -"EngChgEcoResProductLifeCycleStateRule_Blocked" has value "Blocked". Than the Item ID field will not show that item in the lookup.

How can I achieve this can anyone help. 

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Have you opened the view and see whether the view has records?

    Just delete the ranges one by one and see which one is causing the issue.

    Thanks,

    Girish S.

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Done the Enum changes. But It's not working

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    You need to set the Enum element name. Not the labels. Just try setting "Allow" on the range and check.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Enabled is the label, can you try using 'allow' which is its enum value.

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Hi Mohit/Girish,

    Yes I have blocked option and enabled.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Also, the Blocked status field doesn't has Enable Enum values. Where did you add that Enum element from?

    Thanks,

    Girish S.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Have you set the relation between two tables in a query.

    Also open the view in table browser and check whether the view has been built in correctly and data's are loading correctly.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Do you have value 'Enabled' in Blocked Field? In standard, this enum has 3 values Allow, Warning and Error.

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Add condition on ItemId Field lookup in D365FO

    Hi ,

    I have written the following code. But it's not showing any Item.

    I have Created a Query and added two Data sources using Inner Join and Added that Query in a View .

     [FormControlEventHandler(formControlStr(SalesTable, SalesLine_ItemId), FormControlEventType::Lookup)]
        public static void SalesLine_ItemId_OnLookup(FormControl sender, FormControlEventArgs e)
        {
            SysTableLookup      sysTableLookup  = SysTableLookup::newParameters(tableNum(InventTable_View_CAP), sender);
            
            // Add the lookup columns
    
            sysTableLookup.addLookupfield(fieldNum(InventTable_View_CAP , ItemId));
            //sysTableLookup.addLookupMethod(tableMethodStr(InventTable_View_CAP , defaultProductName));
            //sysTableLookup.addLookupfield(fieldNum(InventTable_View_CAP , NameAlias));
            //sysTableLookup.addLookupfield(fieldNum(InventTable_View_CAP , ItemType));
            //sysTableLookup.addLookupfield(fieldNum(InventTable_View_CAP , Product));
            //sysTableLookup.addLookupfield(fieldNum(InventTable_View_CAP , PmfPlanningItemId));
    
    
            // Run the lookup
            sysTableLookup.performFormLookup();
    
            //cancel the call to super() to prevent the system from trying to show
            //the lookup form twice and cause an error.
            FormControlCancelableSuperEventArgs cancelableSuperEventArgs = e as FormControlCancelableSuperEventArgs;
            cancelableSuperEventArgs.CancelSuperCall();
        }

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Add condition on ItemId Field lookup in D365FO

    You can use this as how you use table in lookup query.

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans