D365/AX7: Computed Column/Field In View Using Method & SQL Statements

Requirement

Adding a Computed Column/Field In View Using Method & SQL Statements.

Sample Code

  1. Add a new method “Computed” in your view.You can fully utilize SQL case statements, SQL Functions, SQL direct statements as per your requirements.Untitled
  2. Add a new string computed column or field in your view.Capture
  3. Change the property of computed column and select your method name in “View Method” property.Untitled
  4. Build and Synchronize the project.Your view is now ready to use.
  5. You SQL View should look like this.UntitledCheers …Piyush Adhikari

D365/AX7: Debug Batch Jobs In Visual Studio Using Process batch.exe

Requirement

There are many process in Microsoft Dynamics 365 Finance and Operation which run in background as a batch jobs. The Debugging of Batch Jobs In Visual Studio is very common requirement.

Steps

  1. Go the Debug Menu & Click on “Attach To Process”.Untitled
  2. Show process from all users should be selected  YES
  3. Attach To Value should be -Automatic: Managed (v4.6, v4.5, v4.0) code
  4. Select Process “Batch.exe” from available processes & run your batch job. Breakpoint will hit and you will be able to debug your code.Untitled

AX7/D365: JSON DeSerialization/Parsing Using FormJsonSerializer

Requirement:

Developer is consuming an external REST web-service in D365/X++ . Response is in the JSON format.  Developer needs to DeSerialize incoming JSON so that values can be used later in the system.

Sample Code:

  1. Create a contract class
    [DataContract]
    class JSONContract
    {
        String50 parmFirst, parmSecond;
        [
            DataMemberAttribute('parmFirst')
        ]
        public String50 parmFirst(String50 _parmFirst = parmFirst)
        {
            parmFirst = _parmFirst;
            return parmFirst;
        }
        [
            DataMemberAttribute('parmSecond')
        ]
        public String50 parmSecond(String50 _parmSecond = parmSecond)
        {
            parmSecond = _parmSecond;
            return parmSecond;
        }
    }
  2. Sample Class
    class RunnableClassABC
    {
        /// <summary>
        /// Runs the class with the specified arguments.
        /// </summary>
        /// <param name = "_args">The specified arguments.</param>
        public static void main(Args _args)
        {
            str             json;
            List            values = new List(Types::String);
            ListEnumerator  value;      
            json = '[{"FieldValues": [{"parmFirst": "ValueFirst", "parmSecond": "ValueSecond", "parmList":[{"parmFirst": "ValueFirst", "parmSecond": "ValueSecond"}] }]}]';
            // Deserializing Json
            values = FormJsonSerializer::deserializeCollection(classnum(List), json, Types::Class, classStr(JSONContract));
            value = values.getEnumerator();
            while(value.moveNext())
            {
                JSONContract    JSONContractCurrent = value.current();
                info(strFmt("%1    %2",JSONContractCurrent.parmFirst(), JSONContractCurrent.parmSecond()));
            }
        }
    }