Skip to main content

Notifications

Announcements

No record found.

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 50

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“

  • Marvin Richter Profile Picture
    50 on at
    RE: How do I get the value of the filter code 2 from the WHSInventTable?

    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!

  • Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How do I get the value of the filter code 2 from the WHSInventTable?

    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
    50 on at
    RE: How do I get the value of the filter code 2 from the WHSInventTable?

    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];
    }

  • Suggested answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How do I get the value of the filter code 2 from the WHSInventTable?

    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
    50 on at
    RE: How do I get the value of the filter code 2 from the WHSInventTable?

    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

  • Verified answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How do I get the value of the filter code 2 from the WHSInventTable?

    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]; 
    }

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,013 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans