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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Will my scalar value function created in SQL be deleted if compile and sync

(0) ShareShare
ReportReport
Posted on by

Hi I just want to know if there are any of you who have tried creating scalar value function (user-defined) function in SQL and use it in AOT view ?

The computed value in the function will be stored in a field in view. My worry is , am I doing it the wrong way? Is there an AOT related object that does the same thing as the SQL function behaves? It seems that since tables are created in AOT , maybe the function too?

I'm using Dynamics AX 2012, SQL Server 2012

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,284 on at

    Hi venAx,

    You can use computed columns daxmusings.codecrib.com/.../computed-view-columns-in-ax-2012.html

    If it's not enough for your task, could you please explain what do you want to achieve?

  • Community Member Profile Picture
    on at

    The reason I want to use scalar value function in SQL is for it to be accessible in other views not just the one view..

    My function's purpose is to compute the elapsed date time between two dates considering the data in table workcalendarline. In this function,  I have loops , variable declarations, and parameters.  This function returns only a decimal data type so that when called in view, a field will already hold the return value..

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi venAx,

    It's always better to use AX native dev tools than direct SQL but if you don't want or can't because of some reason there is a work around.  You can create view in AOT and then alter it's definition using SQL statement to add whatever you want. As you know AX will drop your changes on next sync.  However, you can add code to alter view again into Application.dbSynchronize() method.

    In this method you can find standard code to create store procs and DB triggers, so you can use it as example.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans