Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Answered

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

Posted on by 5

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
    Marvin Richter 5 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
    Mohit Rampal 12,547 Super User 2024 Season 1 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
    Marvin Richter 5 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
    Mohit Rampal 12,547 Super User 2024 Season 1 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
    Marvin Richter 5 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
    Mohit Rampal 12,547 Super User 2024 Season 1 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans