web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 54

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)
  • Marvin Richter Profile Picture
    54 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,563 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
    54 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,563 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
    54 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,563 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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,098

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 215 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans