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

Notifications

Announcements

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

Responsible AI policies

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

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Volodya Profile Picture

Volodya 2

#2
tgudwanski Profile Picture

tgudwanski 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans