I have a bug in web service where we need to make a parameter read. There is a code in validateWrite(..) method of the table that adds an AIFFault::checkFailedLogFault if the field is being changed.However, when testing this using the web service in the visual studio solution no error is being raised and the web service is being allowed to change parameter even though when I step into debug the AIFFault::checkFailedLogFault is being called.
There are four ways to achieve this through x++ code. There is nothing that web service can do to make visual studio or any other client stopped editing, because web services are asynchronous in nature and web services are not called on the assignment of the value in any client ( I believe user is associating project to the lines from the client and not the code behind web service is doing that). It will raise error when the client submit the code and will fail the creation of the record in case of any error.
1) Write the code on the validate write of the table and return false from there with the checkFailed error message.
2) Delete the field from the query so that user can’t see that field.
3) Manipulate through code in the prepareForSaveEntended method of the Axd class and check if there is a project, blank the field or ignore the user value and use the table value.
4) Use the removeFieldAsTouched() method
FormReferenceGroupControl testReferenceControl = Grid.addControl(FormControlType::ReferenceGroup, #controlName);
Below is the example that shows how to set properties of the parts through code
List partList = new List(Types::Class);
for (partListCounter = 1; partListCounter <= formPartList.partCount() ; partListCounter++)
I was just brainstorming about the dynamics ax interview questions and I came up with the following image that could list down the minimum requirements and it gives a good picture about the question to be asked in in the Dynamics Ax technical interview.
Scenario: I have a menu item that calls some class to do manipulation on the list page Form and I need to refresh the list page now. List pages do not allow writing of code on the Form, as they used interaction class.
Solution: You can write the code on list page buttons by setting DisplayTarget property to “Client” from auto. However after this change, you won’t be able to sue this button on the EP, so if you are thinking of using the same list page on the EP and planning to use the same button there, then do not do it. However f your domain is only the Form then you are good to do this.
Any ways override the clicked method and call research() of the data source to do this
User is checking the rows in the grid to mark them for deletion, I want to get the number of checked records to do some thing
Use the buffer_Ds.recordsMarked().lastIndex() to check the number of the records that are marked for deletion.
User has marked the multiple records for deletion on the Form, now I want to do some manipulation on the deletion and refresh the Grid or the Form. What should I do
Never write the research code in the delete method because the delete method on the Form is called per row and calling research would break this behavior, since research calls the executeQuery(). DeleteMarked() is the good place to write the research code since it is called once if there are multiple records, you should write the research code just after the super() call.
Note: The deleteMarked() method is not called when there is a single record for the deletion.
This article is about creating inbound web service. Let’s go through step by step to understand the development of it.
First we will discuss the concepts then we will go deeper in the implementation.
How the component are interacting with each other
Steps to develop a web service
1. Create a query
a. Remember to prefix it with Axd
b. Add the fields in this query that you want to expose to the user
c. Right click the fields property and set it to “No”.
d. Remember to delete ‘_1′ suffix from the data source’s name
2. Go to tools –> Wizard –> Aif Document wizard
3. For the inbound service, you need to check the “create” check box, since the inbound service will be creating the record. For generating AxBc class, just click the Generate Axbc check.
4. On finishing this wizard, you would have the project with the axbc and Axd classes.
5. Remove the cache method from the axbc class to remove the error
6. Your web service is ready
7. Right click the service and click addins –> register service.
8. Create a inbound port to expose this service
Some important method
Where to write code for the validations and saving?
Axd**** class –> prepareForSaveExtended() method is the place to write that type of code. This method is called twice for each data source, first time before saving record, then after saving the record
You can write code like below for your validation and saving the records.
axCustable= _axBcStack.top(); switch (_recordProcessingContext)
// Ensure CustTable record is saved before any of its dependent child records
// Ensure CustTable record is saved
How to default Value in the webservice?
Write the code for it in the Ax***** classes for your document. Use the parmMethods to do that. The code some thing like below will be good example
protected void setIsTestField()
if (this.isMethodExecuted(funcName(), fieldNum(TestTable, IsTestField))
How to make fields not required or un mandatory on the web service?
If you have a field that is mandatory on the table but you want those fields to be not required on the class, you have to override the initMandatoryFieldExemptionList() on the Ax*** class. For instance, for custTable, over ride the method in AxCustTable class and write code like below
protected void initMandatoryFieldsExemptionList()
How to make fields mandatory on the web service?
If you have a field that is not mandatory on the table but you want those fields to be required on the webservice, you have to override the initMandatoryFieldMap() on the AxD*** class. For instance, for custTable, over ride the method in AxDCustTable class and write code like below
Do we have reference group type functionality on the Web service?
If you have foreign key of some table in your document table, you probably don’t want that record id to be taken as input from the user, and you probably be looking for the user understandable value from him. For that type of functionality, you have to override the expandSurrogateKey(…) method on your Axd class and make a natural key on the foreign key table. This natural key would be shown to the user.
I want to write customized code that could resolve surrogate key ?
Over ride the getForiegnkeyValue (..) method on your Axd class and you can write code like below to resolve the references
ret = super(_axdBaseProperty, _sfkReplacementValue);
case tableNum(TestTable) :
case fieldNum(TestTable, TestField):
ret = TestTable::Find(_sfkReplacementValue.value(‘TestNaturalKeyName’)).RecId).RecId;