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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Trying on SysOperation framework

(0) ShareShare
ReportReport
Posted on by 596

Hi guys,

I'm learning on SysOperation Framework, and currently confuse about some error.

So the step are :

1. Create Query, let say query name MyCustTransOpen

2. Create Contract class like this :

[DataContractAttribute, SysOperationContractProcessingAttribute(classstr(SysOperationAutomaticUIBuilder))]

class MyCustTransOpen_Contract

{

 str packedQuery;

[DataMemberAttribute, AifQueryTypeAttribute('_packedQuery', queryStr(MyCustTransOpen))]

public str parmQuery(str _packedQuery = packedQuery)

{

  packedQuery = _packedQuery;

  return packedQuery;

}

      

public Query  getQuery()

{

return new Query(SysOperationHelper::base64DEcode(packedQuery));

}

public void setQuery(Query  _query)

{

packedQuery = SysOperationHelper::base64Encode(_query.pack());

}

}

Before I proceed, it already give me error, precisely in the line where I give red color.

It says the variable already declare. it that code, wrong?

Thanks

I have the same question (0)
  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    What exactly does it say? More specifically, which of the two variables is it about? If it's not clear, what if you temporary remove the default value (= packedQuery)?

  • Deekshit Addepalli Profile Picture
    on at

    Are you trying to assign _packedQuery to packedQuery or packedQuery to _packedQuery?

    I would remove the default assignment in the parmQuery method block and leave it just as public str parmQuery(str _packedQuery) and then inside the method, declare it the way you intend to.

  • Voltes Profile Picture
    596 on at

    Hi,

    To be honest, I'm not too sure. Since I'm still learning and I just trying to follow this blog ->

    dynamicsaxtechnicalstuff.blogspot.com/.../create-batch-job-using.html

    If you can be so kind to take a quick look and some advice, is the approach already obsolete perhaps.

    Thanks

  • Voltes Profile Picture
    596 on at

    And just some addition, actually what I want to try to achieve is like this

    :

    1. I have a form, and inside there is 1 combo box with an Enum selection

    2. On particular selection after user select it, I will need to run a batch job.

    3. This batch job (which is the one I'm learning now), will have some procedure to insert some information to another table (lets say for example : it is a log table)

    For point no 2. also I haven't decided whether to use the Form-ModifieldField method, or create an EvenHandler class.

    Kindly advise.

    Thanks,

    V

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    The only class to showed to us is for something that you didn't mention in your requirements at all. You need a data contract class a query if you want to allow users to modify the query (e.g. adding filters), or set the query from code outside the batch. If you don't need that, you don't need your code either.

    And it's not clear what you have with the requirements you've mentioned.

  • Voltes Profile Picture
    596 on at

    Hi Martin,

    Sorry for the confusion, which is true, the initial question about the error is as mentioned also it is "On learning" basis. And I'm following the link which I described later on. So at that point, my concern is why it is throwing error. Anything false in that blog that I'm following ?

    The requirement is my real task or the real issue that I want to resolve, this is after the "learning" completed.

    Hope you understand.

    Anyway for the error, strangely now is gone, so I don't know what's wrong that time. But anyway for the real issue, still open for suggestion, should there is a good and simple blog close to that issue. And will be more helpful if it is in D365 because most of the blog I found is for AX2012.

    Thanks.

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    The framework is pretty much the same as in AX 2012, therefore you can still use information sources for AX 2012. People didn't have reasons to update their blog posts as it's the same.

  • Voltes Profile Picture
    596 on at

    Hi Martin or all,

    What I find it hard, as beginner is actually the interconnection between those 3 or 4 classes, and all the blogs obviously explaining with their own style.

    Like for example, currently I have weird error, but it is runtime error since during Build is ok. It is in my Controller class, whereby the Contract class is Null. I put the code as below:

    class MyController

       extends SysOperationServiceController

    {

       public ClassDescription caption()

       {

           return "Service controller";

       }

       public static MyController newFromArgs(Args _args)

       {

           MyController       _Controller;

           MyContract         _Contract;

           MyTransactionLineTbl            MyTransactionLineTbl;

           Query               query;

           _Controller = new MyController();

           //initialize from args

           _Controller.initializeFromArgs(_args);

           //get data contract

           _Contract = _Controller.getDataContractObject('MyContract);

           //get record

           if (_args && _args.dataset() == tableNum('MyTransactionLineTbl'))

           {

               MyTransactionLineTbl = _args.record();

               //new query

               query = new Query(queryStr(MySimpleQuery));

               //add range

               query.dataSourceTable(tableNum(MyTransactionLineTbl)).addRange(fieldNum(MyTransactionLineTbl, RecId)).value(queryValue(MyTransactionLineTbl.RecId));

               //set query

               _Contract.setQuery(query);

           }

           return _Controller;

       }

       public static void main(Args    _args)

       {

           MyController  _Controller;

           ;

           _Controller = MyController::newFromArgs(_args);

           _Controller.startOperation(query);

       }

    }

    The error is at line _Contract.setQuery() where I put in red whereby runtime error saying "Null reference".

    The Contract Class it self is like below:

    [DataContractAttribute]

    class MyContract

    {

       str                     packedQuery;

       [DataMemberAttribute, AifQueryTypeAttribute('_packedQuery',queryStr(MySimpleQuery))]

       public str parmQuery(str _packedQuery = packedQuery)

       {

           packedQuery = _packedQuery;

           return PackedQuery;

       }

       public Query    getQuery()

       {

           return new Query(SysOperationHelper::base64Decode(packedQuery));

       }

       public void setQuery(Query _query)

       {

           packedQuery = SysOperationHelper::base64Encode(_query.pack());

       }

    }

    Can I have an advice how to resolve this ?

    Thanks,

  • Community Member Profile Picture
    on at

    Hi,

    Yes, I do agree, even though it is not 'pretty much different' but still it is not the same as the programming platform and style for D365 is also change. For example, some attribute that actually already obsolete like "SysEntryPointAttribute" etc.

    And the fact that the blog does about the respective person way and logic, it is hard to follow, and decide which way is fit with our requirement because by selecting to follow "A" it may not applicable to our own needs. One example is to run that class from Menu Item, in the Property -> Object, some will call SysOperationServiceController class and put the "processing" method in Parameter, while some just call direct to their controller class.

    It will be even harder to understand if that some one is not coming from AX Developer.

    Cheers,

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Yes, you don't have to implement your own specialized controller if you're happy with the logic of the standard controller. But the usual approach for real implementations (not just tests and demo) is creating your own controller and providing a caption and such things. Then the operation name is also validated by the compiler and it's covered by cross-references (which isn't the case if you just set it in the menu item's property).

    SysEntryPointAttribute was related to web services, not directly to the SysOperation framework, therefore it isn't something you should worry about in this case.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans