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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

How do I get the value of the filter code 2 from the WHSInventTable?

(0) ShareShare
ReportReport
Posted on by 60

Hey,

 i want to get the filter code 2 from a specific dataset of the EcoResProductDetailsExtended.

It should look like this example:

public Str getFilterCode2()

{

               Select firstonly RecId from whsInventTable

                    where  [….];

               return whsInventTable.FilterCode[2] // This obviously doesn't work :D

}

Unfortunately the WHSInventTable works like this:

- WHSInventTable only stores the column FilterCode (not FilterCode1,2,3,…)

- The DataField Property of the form access the value of the WhsInventTable with „FilterCode[2“

I have the same question (0)
  • Verified answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Marvin, If you check WHSInventTable in SQL Server, you will the value is saved per FilterCode field in a record, such as value in FilterCode2, FilterCode3 etc.

    Your select statement is incorrect as you are selecting only RecId from WHSInventTable and returning FilterCode[2. If you want, you can select FilterCode[2 and return it as below.

    public Str getFilterCode2()
    {
        WHSInventTable whsInventTable;\
        
        Select firstonly FilterCode[2] from whsInventTable
        where  [….];
    
        return whsInventTable.FilterCode[2]; 
    }

  • Marvin Richter Profile Picture
    60 on at

    I guess I didn't express myself correctly. Yes, that would certainly be correct if the column existed on the table, but unfortunately it doesn't. Unfortunately, I don't know how the data model works here. Because: FilterCode exists, FilterCode[2], [3] etc. does not. Unfortunately, your statement would lead to the error that no string array can be made from a string because it only knows FilterCode as a column. The image below explains the structure of the WHSInventTable.

    pastedimage1681807040627v1.png

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    This is an array field, so at Table level you will see only FIlterCode but it has array elements. Please check WHSFilterCode EDT. I have tried the code and it works. Please test and let me know if any issues.

    pastedimage1681807894257v1.png

  • Marvin Richter Profile Picture
    60 on at

    Thanks for the fast answers, but i still have an error at the build. It says "Join expected"  right before the "[". 

    This leads me to believe that x doesn't know this syntax.

    To make sure I didn't copy anything wrong, here is the full code:

    public Str getFilterCode2()
    {
        WHSInventTable whsInventTable;
        
        Select firstonly FilterCode[2] from whsInventTable
        where this.ItemId = whsInventTable.ItemId;
        
        return whsInventTable.FilterCode[2];
    }

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    May I know on which table/class are you creating this method. What 'this' denotes in this.ItemId

    Instead of this.ItemId = whsInventTable.ItemId please try whsInventTable.ItemId = this.ItemId. If still get same error then you need to create either join or create ItemId variable, map this.ItemId to variable and pass the variable in select statement.

  • Marvin Richter Profile Picture
    60 on at

    There just was a missing "="

    That's exactly why I looove to switch between "normal" SQL statements and the x++ SQL statements at work (not) :D

    Thanks a lot for your help!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Mallesh Deshapaga Profile Picture

Mallesh Deshapaga 1,066

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 212 Super User 2026 Season 1

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 136 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans