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)

No metadata class defined for data contract object

(0) ShareShare
ReportReport
Posted on by 125

I am trying to create a Batchjob. For that initially i have created a class and added a method. Now i am attaching this class with the Action Menu item. and generated Incremented CIL. But when i open the menu item i am Getting the error. bellow is my code and relevent screen shots. 

[DataContractAttribute]
class BatchJobDemoClass
{
}

[DataContractAttribute]
public void xmlGeneration(Args _args)
{
XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeAccount;
XmlElement nodeName;
CustTable custTable;
#define.filename(@'C:\\Users\user\Desktop\productsXML.xml')
;
doc = XmlDocument::newBlank();
nodeXml = doc.createElement('xml');

doc.appendChild(nodeXml);
//Determines the runtime
if (xSession::isCLRSession())
{
info('Running in a CLR session.');
}
else
{
info('Running in an interpreter session.');

//Determines the tier
if (isRunningOnServer())
{
info('Running on the AOS.');
}
else
{
info('Running on the Client.');
}
}

while select custTable
{
nodeTable = doc.createElement(tablestr(CustTable));
nodeTable.setAttribute(fieldstr(CustTable, RecId),int2str(custTable.RecId));
nodeXml.appendChild(nodeTable);
nodeAccount = doc.createElement(fieldstr(CustTable, AccountNum));
nodeAccount.appendChild(doc.createTextNode(custTable.AccountNum));
nodeTable.appendChild(nodeAccount);
nodeName = doc.createElement(fieldstr(CustTable,CustGroup));
nodeName.appendChild(doc.createTextNode(custTable.CustGroup));
nodeTable.appendChild(nodeName);
}
doc.save(#filename);
info(strFmt("File %1 created.", #filename));
}

action.PNGAction_5F00_Pro.PNG33080.error.PNG

Please help me with this i am new to Batch Jobs.

*This post is locked for comments

I have the same question (0)
  • Jie G Profile Picture
    on at

    This error means that you are trying to use a type as a data contract that is not a valid data contract type.

  • Jie G Profile Picture
    on at

    Please refer to : http://www.artofcreation.be/2014/03/25/dynamics-ax-no-metadata-class-defined-for-data-contract-object/  for how to troubleshoot this issue.

  • Verified answer
    Community Member Profile Picture
    on at

    You only have that two methods?

    If you are going to call the class in a menuItem, the class must have the main method.

    Are you trying to run your code in a batch process? then look the class tutorial_RunBase that will gave you the basic method you need to overwrite.

  • venkatpasumarthi Profile Picture
    125 on at

    I already refereed to the same blog, but i am unable to understand what is wrong in the above code. please suggest me how to approach.

  • venkatpasumarthi Profile Picture
    125 on at

    Thank you @Tatiana Garcia, I have gone through the suggested class. Give me a clarification

    1) do i need to write above code in run method?

    2) How to attach this class to batch job?

  • Community Member Profile Picture
    on at

    Hi,

    You need to create an Action MenuItem, you will see the Batch tab in the Dialog, select the batch setup and this will run in a batch.

    Remember that you batch services must be running.

    Thanks!

  • goyalsachin6 Profile Picture
    21 on at

    I had the similar issue when I put the development comments on top of class declaration. It is silly as comments should not be considered while taking any object. After removing comments it worked fine.

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