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

Notifications

Announcements

Community site session details

Community site session details

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

Add condition on ItemId Field lookup in D365FO

(0) ShareShare
ReportReport
Posted on by 113

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. 

I have the same question (0)
  • GirishS Profile Picture
    27,829 Moderator on at

    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
    113 on at

    Done the Enum changes. But It's not working

  • GirishS Profile Picture
    27,829 Moderator on at

    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
    12,565 Moderator on at

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

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Mohit/Girish,

    Yes I have blocked option and enabled.

  • GirishS Profile Picture
    27,829 Moderator on at

    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
    27,829 Moderator on at

    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
    12,565 Moderator on at

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

  • HARISH MEHRA Profile Picture
    113 on at

    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
    27,829 Moderator on at

    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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 325 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans