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 :
Microsoft Dynamics AX (Archived)

Views computed columns issue

(0) ShareShare
ReportReport
Posted on by

Hi,

I am trying to understand computed columns. I am working on an example that won't work for me. Let's say that I have a view consisting of InventTable. I want to add a computed column where I fetch the UnitId from InventTableModule.

I created a method that looks like this but the in my view the computed column is empty. What am I doing wrong?

private static server str unitId(int branchNum)

{

   #define.ViewName(CAP_Test)

   #define.DataSourceName("InventTable_1")

   #define.FieldToComputeWith("ItemId")

   str sReturn, sTemp99, sTemp98;

   DictView dictView2;

   //-------- EndOf variable declarations. ---------

   dictView2 = new DictView(tableNum(#ViewName));

   sTemp99 =

       "(SELECT top 1 InventTableModule.UnitId"

       + " from InventTableModule "

       + " where InventTableModule.ModuleType =  0 AND "

       + " InventTableModule.ItemId = '" ;

   stemp98 = dictView2.computedColumnString

               (

                   #DataSourceName,

                   #FieldToComputeWith,

                   FieldNameGenerationMode::WhereClause,

                   true

               );

   sReturn = sTemp99 + sTemp98 + "')";

   return sReturn;

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Heinz Schweda Profile Picture
    1,367 on at

    Hi Sebastian, you have to remove the two single Quotation marks (').

    private static server str unitId(int branchNum)

    {

      #define.ViewName(CAP_Test)

      #define.DataSourceName("InventTable_1")

      #define.FieldToComputeWith("ItemId")

      str sReturn, sTemp99, sTemp98;

      DictView dictView2;

      //-------- EndOf variable declarations. ---------

      dictView2 = new DictView(tableNum(#ViewName));

      sTemp99 =

          "(SELECT top 1 InventTableModule.UnitId"

          + " from InventTableModule "

          + " where InventTableModule.ModuleType =  0 AND "

          + " InventTableModule.ItemId = " ;

      stemp98 = dictView2.computedColumnString

                  (

                      #DataSourceName,

                      #FieldToComputeWith,

                      FieldNameGenerationMode::WhereClause,

                      true

                  );

      sReturn = sTemp99 + sTemp98 + ")";

       print(sReturn);

      return sReturn;

    }

  • Community Member Profile Picture
    on at

    Easy one. :)

    Thx!

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans