Quantcast
Channel: Martin Dráb's Activities
Viewing all 17532 articles
Browse latest View live

Using insert recordset in temporary table

$
0
0

I have created two instance of single temporary table eg: table1 and table2,

First i filled table1 data and then,

I am trying to insert table1 data into table2 using insert_recordset through following code

insert_recordset table2 (field1,field2)

select field1,field2 from table 2;

But it when debugger comes to execution of this statement, AX doesn't respond and have to restart.

What could be the problem...? 


Disaster Recovery for Dynamics 365 (Finance & Operations) online

$
0
0

Hi,  Can we backup the D365 (Finance and Operations) DB to Azure storage, Just like we do for Dynamics 365 (CRM).  What is best way to do disaster recovery for D365 Online (ERP) apart from requesting from MS for backup.

Regards,

Vinod

Number sequence without using class

$
0
0

Hi,

Please suggest on how to create a number sequence without using any class in ax 2012 r3.

Please advice.

Regards,

AXTechie 2120

Add a valid time state key to an existing table

$
0
0

In my earlier days I was not aware of the Valid Time State Key functionality. So a table which should've implemented this functionality I built with code. There is no unique index and then on validateField I check that no overlap occurs (I also wrote code on update and insert to double check). Now my perfectionist side wants to change this table to a Valid Time State Table.

Basic logic tells me that this will not create any issues on client data, but I am still unsure.

I guess the safe method will be to live with this *primitive table I built........but if I really wanted to change it, am I correct to say that changing it to VTS will not create any issues? Assuming my code was correct in preventing FromDate..ToDate overlap.

Thanks for reading

How to connect projects to Classes, etc in Modelelement? (Dynamics AX 2012 R2)

$
0
0

When Querying ModelElement in the model database , How do you connect classes to a project?  For the classes , methods, etc you can use the roothandle field as a where clause Criteria, but when i am looking at a project, the roothandle cannot be used to connect to the classes and other elements in a project.  I am dealing with trying to decipher what all of the various code, etc in a company's system is, and how it is all connected.  I have tried looking in the ModelElement &  Modelelementdata tables as well as the utilelements view.  Does anybody have a good solution here?  

Also, whether form the front end or the database, is there any way to generate something like a class diagram?  I am new to dealing with Dynamics, and only one division of my company is using  Dynamics AX 2012 R2. we are trying to figure out the full extent to which their environment has been customized. 

How to fetch records between two date fields in X++ query on refereceFieldLookup?

$
0
0

Hi All,

I'm facing difficulty while fetching records between two utcdatetime fields by using X++ query on refereceFieldLookup.

I've querying a View which has the ValidFrom and ValidTo fields.

the data source for the view is HcmPositionWorkerAssignment table and the View has ValidtimeStateProperty set to NO.

I'm aware of the below solution, to fetch from ValidtimeStateTable , but in my scenario I've wanted it ValidtimeStateProperty as NO.

 query.validTimeStateDateTimeRange(rangeStart, rangeEnd);

Below expression I've tried  but its not filtering based on the query value .I can see the ranges has been added to the query using query.Tostring() method, but it not shows any records in the refereceFieldLookup , not between the given date range

 utcDateTime             rangeStart, rangeEnd;
 date                    startDate, endDate;
 TimeOfDay               startTime, endTime;
 QueryBuildDataSource    qbdsHcmPositionWorkerAssignment;
 QueryBuildRange         qbrWorker,qbrPosition;
   
 // set range variables
  startDate   = 07\01\2018;       // day\month\year
  endDate     =30\06\2019;       // day\month\year

  startTime   = str2time('12:00:00 am');     //GMT, NOT user time zone - this is how stored in the table
  endTime     = str2time('12:00:00 am');     //GMT, NOT user time zone - this is how stored in the table

  rangeStart = DateTimeUtil::newDateTime(startDate,startTime);
  rangeEnd   = DateTimeUtil::newDateTime(endDate,endTime);

  qbdsHcmPositionWorkerAssignment          = query.addDataSource(tableNum(HcmPositionWorkerAssignmentView));
  qbrPosition = qbdsHcmPositionWorkerAssignment.addRange(fieldNum(HcmPositionWorkerAssignmentView, DataAreaId));

  qbrPosition.value(strFmt('(( %1.%2 >= "%3") && (%1.%4 <= "%5"))',
            qbdsHcmPositionWorkerAssignment.name(),
            fieldStr(HcmPositionWorkerAssignmentView, ValidFrom),datetime2Str(rangeStart),
            fieldStr(HcmPositionWorkerAssignmentView, ValidTo),datetime2Str(rangeEnd)));

//below is the sql querystring generated

SELECT * FROM HcmPositionWorkerAssignmentView(HcmPositionWorkerAssignmentView_1)
WHERE (((( HcmPositionWorkerAssignmentView_1.ValidFrom>= "7/1/2018 12:00:00 am") && (HcmPositionWorkerAssignmentView_1.ValidTo <= "6/30/2019 12:00:00 am"))))
AND ((Worker = 68719484600)) AND ((Position = 68719480329))

Read and move all .csv file of a folder in Dynamics 365 for Operation

$
0
0

Dear All,

I know D365FO is cloud service
I have a folder in a private server and after fixed time system will scan all files in the folder for import action.

After import success it will move the file to other folder.

I don't know D365FO have ability to do that or not, please help me.

Thanks!

Debug code in Application Suite

$
0
0

Is there anyway I can debug the class in the Application suite without modifying the code? 

Thank you. 


Batch multi-threading

$
0
0

I have a batch job which is running perfectly fine without multi threading.

I am trying to make this batch job support multi threading.

In order to do  so the batch job form should ask user to enter no. of threads to be executed for the batch job.

Have gone through http://www.artofcreation.be/2010/10/03/batch-multithreading/comment-page-1/#comment-51120

But still cant figure out how to make this work in D365.

My understanding is  that the contract class should be providing me with number of threads parameter, controller class should have construct method for my main class (which has the business logic).

Please let me know if my understanding is wrong/correct & please share some content showing how to convert existing batch job to a multi thread batch job.

How can i send a nested List response in XML using AX 2012 Custom Service

$
0
0

Hi All,

I am trying to achieve the below XML response where when we pass the Customer ID and TransDate as input, system should send the Sales ID's and the Invoice ID's which are related to the input parameters.

Service Request:

<?xml version="1.0"?>

<LoginResponse>

    <CustId>1234ab5678</CustId>

    <Date>10/10/2018</Date>

</LoginResponse>

 

 

Expected Service Response:

 

<?xml version="1.0"?>

<CustomerInfoResponse>

   <CustId>1234ab5678</CustId>

   <Date>10/10/2018</Date>

   <SalesOrder>

       <SalesId>800000XXX1</SalesId>

       <SaleTransDate>10/10/2018</SaleTransDate>

       <Address>123 MG Road, 219435</Address>

       <Invoice>

           <InvoiceNumber>914200XXX1</InvoiceNumber>

           <InvoiceNumber>914200XXX2</InvoiceNumber>

           <InvoiceNumber>914200XXX3</InvoiceNumber>

       </Invoice>

   </SalesOrder>

   <SalesOrder>

       <SalesId>800000XXX2</SalesId>

       <SaleTransDate>10/10/2018</SaleTransDate>

       <Address>456 MG Road, 219445,</Address>

       <Invoice>

           <InvoiceNumber>914200XXX4</InvoiceNumber>

           <InvoiceNumber>914200XXX5</InvoiceNumber>

           <InvoiceNumber>914200XXX6</InvoiceNumber>

       </Invoice>

   </SalesOrder>

   <SalesOrder>

       <SalesId>800000XXX3</SalesId>

       <SaleTransDate>10/10/2018</SaleTransDate>

       <Address>456 MG Road, 219445,</Address>

       <Invoice>

           <InvoiceNumber>914200XXX7</InvoiceNumber>

           <InvoiceNumber>914200XXX8</InvoiceNumber>

           <InvoiceNumber>914200XXX9</InvoiceNumber>

       </Invoice>

   </SalesOrder>  

</CustomerInfoResponse>

 

  Request you all to help me to understand, how can i send the list of both the SalesOrder and the Invoive. 

Email Body attachment

How to Debug problem from external application?

$
0
0

Hi

I created two classes(Contract, and serviceControl), and I have a Service and a ServiceGroup. I drop serviceControl into Service, and drop Service into ServiceGroup. 

Then I wrote code In C# to connect X++. When I test code in X++, the code works well. And when I test code in C#, 99% of code works. However, only one line does not work well. The C# cannot get value from X++. What may cause this problem? How can I Debug this problem? I cannot debug code in VM when I am working in my company's laptop.

(The last picture is the code in C#)

Error in Serialization of JSON Data in x++

$
0
0

I am serializing a JSON that looks like this:

{
        "id": 107,
        "group_id": 6,
        "default_billing": "6538",
        "default_shipping": "6539",
        "created_at": "2016-08-03 11:48:49",
        "updated_at": "2018-08-01 09:58:10",
        "created_in": "Admin",
        "dob": "1900-01-01",
        "email": "XXX@yahoo.com",
        "firstname": "XXX SERVICES LTD",
        "lastname": ".",
        "store_id": 1,
        "website_id": 1,
        "addresses": [
            {
                "id": 138,
                "customer_id": 107,
                "region": {
                    "region_code": "Default",
                    "region": "Default",
                    "region_id": 0
                },
                "region_id": 0,
                "country_id": "NG",
                "street": [
                    "Default"
                ],
                "telephone": "08012345678",
                "postcode": "23401",
                "city": "Default",
                "firstname": "XXX SERVICES LTD",
                "lastname": "."
            },
            {
                "id": 5833,
                "customer_id": 107,
                "region": {
                    "region_code": "Default",
                    "region": "Default",
                    "region_id": 0
                },
                "region_id": 0,
                "country_id": "NG",
                "street": [
                    "Default"
                ],
                "telephone": "08012345678",
                "postcode": "23401",
                "city": "Default",
                "firstname": "XXX SERVICES LTD",
                "lastname": "."
            },
            {
                "id": 5834,
                "customer_id": 107,
                "region": {
                    "region_code": "Default",
                    "region": "Default",
                    "region_id": 0
                },
                "region_id": 0,
                "country_id": "NG",
                "street": [
                    "Default"
                ],
                "telephone": "08012345678",
                "postcode": "23401",
                "city": "Default",
                "firstname": "XXX SERVICES LTD",
                "lastname": "."
            },
            {
                "id": 6538,
                "customer_id": 107,
                "region": {
                    "region_code": "Default",
                    "region": "Default",
                    "region_id": 0
                },
                "region_id": 0,
                "country_id": "NG",
                "street": [
                    "Default"
                ],
                "telephone": "08012345678",
                "postcode": "23401",
                "city": "Default",
                "firstname": "XXX SERVICES LTD",
                "lastname": ".",
                "default_billing": true
            },
            {
                "id": 6539,
                "customer_id": 107,
                "region": {
                    "region_code": "Default",
                    "region": "Default",
                    "region_id": 0
                },
                "region_id": 0,
                "country_id": "NG",
                "street": [
                    "Default"
                ],
                "telephone": "08012345678",
                "postcode": "23401",
                "city": "Default",
                "firstname": "XXX SERVICES LTD",
                "lastname": ".",
                "default_shipping": true
            }
        ],
        "disable_auto_group_change": 0,
        "custom_attributes": [
            {
                "attribute_code": "is_active",
                "value": "1"
            }
        ]
    }
Here's a C# class I used in serializing, I referenced it from my xpp project:
using System.Collections.Generic;
using Newtonsoft.Json;

namespace JsonSerializer
{
    public class CustomerInfo
    {
        [JsonProperty(PropertyName = "id")]
        public int Id { get; set; }
        [JsonProperty(PropertyName = "group_id")]
        public int GroupId { get; set; }
        [JsonProperty(PropertyName = "default_billing")]
        public string DefaultBilling { get; set; }
        [JsonProperty(PropertyName = "default_shipping")]
        public string DefaultShipping { get; set; }
        [JsonProperty(PropertyName = "created_at")]
        public string CreatedAt { get; set; }
        [JsonProperty(PropertyName = "updated_at")]
        public string UpdatedAt { get; set; }
        [JsonProperty(PropertyName = "created_in")]
        public string CreatedIn { get; set; }
        [JsonProperty(PropertyName = "dob")]
        public string Dob { get; set; }
        [JsonProperty(PropertyName = "email")]
        public string Email { get; set; }
        [JsonProperty(PropertyName = "firstname")]
        public string FirstName { get; set; }
        [JsonProperty(PropertyName = "lastname")]
        public string LastName { get; set; }
        [JsonProperty(PropertyName = "store_id")]
        public int StoreId { get; set; }
    }

    public class Address
    {
        public string Id { get; set; }

        [JsonProperty("country_id")]
        public string CountryId { get; set; }

        public string Telephone { get; set; }
    }
    
    public class Root
    {
        [JsonProperty("id")]
        public int Id { get; set; }
        [JsonProperty("group_id")]
        public int GroupId { get; set; }
        [JsonProperty("default_billing")]
        public string DefaultBilling { get; set; }
        [JsonProperty("default_shipping")]
        public string DefaultShipping { get; set; }
        [JsonProperty("created_at")]
        public string CreatedAt { get; set; }
        [JsonProperty("updated_at")]
        public string UpdatedAt { get; set; }
        [JsonProperty("created_in")]
        public string CreatedIn { get; set; }
        [JsonProperty("dob")]
        public string Dob { get; set; }
        [JsonProperty("Email")]
        public string email { get; set; }
        [JsonProperty("firstname")]
        public string FirstName { get; set; }
        [JsonProperty("lastname")]
        public string LastName { get; set; }
        [JsonProperty("store_id")]
        public int StoreId { get; set; }
    }

    public class ConvertToObject
    {
        public string Convert(string jsonString)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings();
            settings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();

            Root root = JsonConvert.DeserializeObject<Root>(jsonString, settings);
            return JsonConvert.SerializeObject(root, Formatting.Indented, settings);
        }
    }
}

This is my Integrator.xpp file
class Integrator
{
    public static void Main(Args _args)
    {
        Integrator::execute();
    }

    public static void execute()
    {
        AddressContract			addressContract;
        List customers;
        CustomerInfoContract    customerContract;

        str baseUrl = "urltogetthejson.com/.../V1";
        str getFullCustomers = baseUrl+"customer/getFullCustomers";
        str filteredCust = getFullCustomers+"?xxxxxxxxxxxxxx";

        JsonSerializer.ConvertToObject serializer;
        str dataList;
        
        List data, address;
        ListEnumerator recEnum, addressEnum, customerEnum;

        System.Net.WebHeaderCollection  headers = new System.Net.WebHeaderCollection();
        headers.Add("Authorization", "Bearer XXXXXXXXXXXXXXXXXX");
        str resp = WebService::getRequest(filteredCust,headers);

        customers = FormJsonSerializer::deserializeCollection(classNum(List),resp, Types::Class,classStr(CustomerInfoContract));

        customerEnum = customers.getEnumerator();
        while (customerEnum.moveNext())
        {
            customerContract = customerEnum.current();
            info(customerContract.FirstName());

        }

        info(strfmt("Response is : %1 ", resp));

        
    }

}

Here's my CustomerInfoContract.xpp class:
[DataContractAttribute]
class CustomerInfoContract
{
    int id, groupId, storeId;
    str defaultBilling, defaultShipping, createdAt, updatedAt, createdIn, dob, email, firstName, lastName;
    List addresses;

    [DataMemberAttribute("id")]
    public int Id(int _id = id)
    {
        id = _id;
        return id;
    }

    [DataMemberAttribute("group_id")]
    public int GroupId(int _groupId = groupId)
    {
        groupId = _groupId;
        return groupId;
    }

    [DataMemberAttribute("default_billing")]
    public str DefaultBilling(str _defaultBilling = defaultBilling)
    {
        defaultBilling = _defaultBilling;
        return defaultBilling;
    }

    [DataMemberAttribute("default_shipping")]
    public str DefaultShipping(str _defaultShipping = defaultShipping)
    {
        defaultShipping = _defaultShipping;
        return defaultShipping;
    }

    [DataMemberAttribute("created_at")]
    public str CreatedAt(str _createdAt = createdAt)
    {
        createdAt = _createdAt;
        return createdAt;
    }

    [DataMemberAttribute("updated_at")]
    public str UpdatedAt(str _updatedAt = updatedAt)
    {
        updatedAt = _updatedAt;
        return updatedAt;
    }

    [DataMemberAttribute("created_in")]
    public str CreatedIn(str _createdIn = createdIn)
    {
        createdIn = _createdIn;
        return createdIn;
    }

    [DataMemberAttribute("dob")]
    public str Dob(str _dob = dob)
    {
        dob = _dob;
        return dob;
    }

    [DataMemberAttribute("email")]
    public str Email(str _email = email)
    {
        email = _email;
        return email;
    }

    [DataMemberAttribute("firstname")]
    public str FirstName(str _firstName = firstName)
    {
        firstName = _firstName;
        return firstName;
    }

    [DataMemberAttribute("lastname")]
    public str LastName(str _lastName = lastName)
    {
        lastName = _lastName;
        return lastName;
    }

    [DataMemberAttribute("store_id")]
    public int storeId(int _storeId = storeId)
    {
        storeId = _storeId;
        return storeId;
    }

}

The program fetches the data correctly from the endpoint but fails in the course of serialization because of the names of some keys that are repetitive.
As with the id key, when I ran and stepped over my codes, I noticed that it was saving each field, but once it encounters the second id key in the address
array, it assigns the value to the id key of the main array as a second iteration and then fail afterwards, I think it's expecting the customer_id but sees
the group_id, then it fails giving the following error:
Microsoft.Dynamics.Ax.Xpp.ClrErrorException:JsonSerializationException: JsonSerializationException ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'JsonSerializer.Root' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array.
JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.

How can I make it not assign the value of id in address to the main id of the array?

Is there any way same with "group by"

$
0
0

Hi

In a table, it has it has ItemNo, InventoryType, and UOM. For example, it look like this 

So if I use while loop to find ItemNo and UOM for this table, I will get {A0001, ea} three times. But After I use "Group by" in ea. I will only get {A0001, ea} one time.

Now, I have to use a while loop to include many tables. But some of tables have the problem same with my example. So I have to use group by to all of tables. But, in X++, it does not allow to use "group by" more then once. So is there any way can do the same way like "Group by"? 

execute bat file with 2 parameters from X++

$
0
0

I would like to execute .bat file from X++.(.bat file include execute stored procedures that output file)

Can any suggest some know how.

I would like to input two parameters from AX screen (from month and to month ) and pass those two parameters to .bat and execute stored procedures based on these two parameters . 


SysTest Framework In D365

$
0
0

Hi All,

  Can you please tell me what changes comes with SysTest Framework in D365 FO?

 And How can I use it for my Automation Unit testing ?

Looking for your suggestions on this.

Thanks.

How to Create a XML attribute through X++ code "<AxTableField xmlns="" i:type="AxTableFieldString">"

$
0
0

Hi All,

 How to create A XML file, where in Subtags consist of Attribute as below 

<Fields>

<AxTableField xmlns="" i:type="AxTableFieldString">""

</Fields>

I have used below code and refer my output.

Code :   {

xmlElementAxTableField = nodeTableFields.appendChild(xmlDoc.createElement("AxTableField"));
xmlElementAxTableField.setAttribute2('type','i','AxTableFieldString');

}

output :

<AxTableField xmlns:d3p1="i" d3p1:type="AxTableFieldString"/>

Issue in adding reference for Metadata API in C# code

$
0
0

I am new to D365. I tried using the metadata API  and encountered these errors.

There are reference issues of Microsoft.Dynamics.Ax that I could not found on nuget. How can I resolve this issue?

 

AX7 Code upgrade - The Model specified on the project cannot be found

$
0
0

Hi guys!

I'm trying to upgrade a custom solution from AX 2012 R3 CU10 to AX 7

I've already done the code upgrade process on LCS and the checked in the code to a VSTS project.

I'm using a local VM as development enviroment. 

I already mapped the metadata folders and refreshed the models.

I can't open any of the vs solutions I downloaded. It raises an error saying:

"One or more projects in the solution were not loaded correctly. Please see the Output Windows for details"

In the output windows there are multiple messages saying:

The model <ModelName> specified on the project cannot be found.

I don't know what is missing, as a I said I refreshed the models after getting thr files from VSTS.

Any ideas?

Automated import with composite entity

$
0
0

Hi

Does anyone know why if it is possible to setup an automated import (using 'Processing directory','Completed directory' etc) when you are using a composite entity ? I have managed to setup a sales order import using XML files and would very much like this import to be automated, is there a way/workaround for allowing this ?

Thanks 

Soeren

Viewing all 17532 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>