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)

Permission Denied for SqlDataDictionary

(0) ShareShare
ReportReport
Posted on by

I am trying to truncate one of our tables in a class to run as a batch job, but keep getting a "Request for permission of type SqlDataDictionaryPermission failed. This is on an AX 4.0 system. I followed MSDN example on acquiring permissions and I am an admin. Here's the code:

   //Truncate table

   new SqlDataDictionaryPermission(

               methodstr(SqlDataDictionary, tableTruncate)).assert();

   sqlDict = new SqlDataDictionary();

   sqlDict.tableTruncate(tableNum(PMF_INVENTTABLEMODULELOG),false);

   CodeAccessPermission::revertAssert();

As I stated, I have admin access to this, so should have the required security key. Though this is displaying the (usr) environment in the class list.

Any help appreciated.

*This post is locked for comments

I have the same question (0)
  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi

    I have recreated the same scenario in a my local AX 4.0 env. with no issues, also in batch mode.

    You are sure that the code is executed on Server side ?

    Look also msdn.microsoft.com/.../bb190039(v=ax.10).aspx

    Regards

  • Community Member Profile Picture
    on at

    yes, i am using server (i am new to AX/X++) here's the lions share of the function:

    server static void run()

    {

       SqlDataDictionary           sqlDict;

       ;

       //Truncate table

       new SqlDataDictionaryPermission(

                   methodstr(SqlDataDictionary, tableTruncate)).assert();

       sqlDict = new SqlDataDictionary();

       sqlDict.tableTruncate(tableNum(PMF_INVENTTABLEMODULELOG),false);

       CodeAccessPermission::revertAssert();

    }

  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi

    Then, how do you move your code in batch ?

    Regards

  • Community Member Profile Picture
    on at

    This is encased in a class that is attached to a journal that runs on a batch server

  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi

    What's happen if you try to call your class with a Job ?

    Regards

  • Community Member Profile Picture
    on at

    Same thing: Denial

  • Klaas Deforche Profile Picture
    2,433 on at

    Hi,

    Create a new table and try truncating that one using the same code. Does it work then?

    Also check the properties on that table. For example is the configuration key enabled? Is the table set to visible? Maybe the cachelookup is playing a role? Is the table set to temp table (I guess not otherwise you would not have to truncate it)? Are you calling the code from withing a transaction?

    Also try just running the code you pasted here without all the rest of your customizations.

  • Community Member Profile Picture
    on at

    I can truncate the table manually (via sql). This is a user created table, not a system table.

    Even running the truncate code by itself gives me the error. Without the truncate code, the program executes, unfortunately without truncating the needed table

  • Community Member Profile Picture
    on at

    Why cant you use DELETE_FROM command?

  • Community Member Profile Picture
    on at

    Something like this

       ttsBegin;

       PMF_INVENTTABLEMODULELOG.skipDataMethods(true);

       delete_from PMF_INVENTTABLEMODULELOG;

       ttsCommit;

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