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

Rest Web API in AX

$
0
0

Hi 

Guide me how to develop rest web services in X++ and also how to change Soap services to Rest 


Projects table - what is it called?

$
0
0

When we export a sales quote onto MS Word and want to link the projects table to the document, we cannot seem to find it:

What is the projects table called?

If we want to add another table to this list, can we do it? If yes, what is the process?

Thanks

DIXF endpoints start failing regularly

$
0
0

hi

We have a recurring integration that starts throwing errors every couple of days. Once this happens we have to create new end-points and then the integration runs fine for some time.

Any idea what is happening? Obviously end points are expiring.

My team is looking into the log files. Asking here just in case anyone already know the root cause 

Integrate Microsoft Dynamics AX2012R3 with AutoDesk Vault

$
0
0

Hi All,

What is the best way to connect AX2012R3 with AutoDeskVault?

I need to get data from AutoDesk Vault to AX.

Remove over layering on Table in Dynamics 365

$
0
0

We are upgrading from AX2012 R3 to D-365.

CustTable(Standard) has been customized in R3 now in the D365 it is over layered object. I created a new package , model and created extension(CustTable.Extension) in our model. When I try to move the custom fields from CustTable to its extension, they are shown as greyed out on the CustTable. Any clues ?

Creating new sales order through DIXF in D365

$
0
0

I want to create a new sales order through DIXF in dynamics 365. I am using Sales order Composite entity for this. My XML file contains 1 header and 2 lines. When i import sales order, it gives error on sales order line and gives error "Sales order number does not allow editing", so kindly tell me how to create sales order through composite data entity.

How to add additional tab in WorkSpace Extension

$
0
0

There is one out of the box Customer Payment Workspace available in D365 for Ops Platform update 20 on the following navigation.

Account Receivable -> Customer Payments.

I want to Customize this workspace to include additional analytical tab by using extension development.

Form Name on the backend is CustPaymentWorkspace.

I have tried to extend this form and change the form pattern to Custom. After that, I was able to create the additional tabs and tab pages but the problem is when I drag and drop the standard tab under my new tab page it has created the duplicate tab instead of dragging the standard one.

In the above image section number 1 contains the standard tab that comes with original form and section number 2 contains the tab that I have created using form extension. As you can see when I drag and drop the "Panorama" tab under the workspace tab page it has duplicated the "panorama" tab and its child objects with the new names.

The workaround for this is I have to explicitly set the visible property to no of the standard tab "Panorama" and after that my form is working fine but my question is, Is there any way I can use the standard components of the form as well in workspace extension instead of duplicating it?

Below is the appearance of the form after my changes but I don't want to hide the standard tabs and create the duplicate ones.

Any help will be much appreciated.

Thanks,

Zahid

Lookup with "contains" filtering

$
0
0

What is the recommended approach for using "contains" filtering in lookups? When using SysReferenceTableLookup, by default the lookup is using a "begins with" filter. If I try to use a wildcard as the first character the * always gets escaped with "\*" when searching. I would prefer to not have to use wildcards at all, and have the lookup use a "contains" filter by default. For example: if I have a value of "12-345, 12345, 12/345" then if i type "12345" then I would want the include the "12-345, 12345, 12/345" record in the lookup results to choose from.


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.

An entity table that has both Item ID and Location ID (aisle) field in the same table?? (urgent)

$
0
0

Hi, i need to find a table that has both Item number and Location ID (aisle) in the same table due to uploading opening balances of inventory on-hand.

So far I've found up to warehouse only.

appreciate the help guys thanks.

Throwing managed exceptions from X++ in D365FO

$
0
0

What I really miss in X++ is the ability to throw exception objects. If you throw an exception in X++, it’s just a number defining what kind of exception it is, which usually says just “Error” (Exception::Error). You also typically add a message to infolog, but the message in infolog and the exception don’t have any link.

Other object-oriented programming languages (such as Java, C# or Python) do it in a much better (object-oriented) way. You throw an object, which contains a lot of information about the error – the type (such as FileNotFoundException), a message, extra details such as the argument name of ArgumentNullException, a stack trace showing which sequence of calls led to the error and so on.

What I consider the most important is the type. This is necessary for meaningful recovery from errors. For example, you’ll go back to user when an error says that an input is invalid, while you may wait a while and try a request a bit later if you know that the error is about a network failure. If all you know is that there is an error, you can’t handle different errors in different ways; you can either stop execution when an error occurs or you’ll ignore all errors. Obviously, neither is ideal.

And other information besides type are is useful too. You may want to log stack trace of where the exception was thrown (not caught), you may want to know which parameter has a wrong value and so on.

I mentioned several times in previous blog posts that D365FO runs on the .NET (CLR) platform and you can catch exceptions objects of CLR exceptions (see Catching exceptions in AX 7). While this is useful, you can’t throw such exceptions from X++, therefore it alone can’t solve our problem.

But making it possible isn’t difficult. Let me show you my proof of concept.

What I wanted to achieve:

  • Ability to throw “normal” .NET exceptions from X++. For example, I want to throw ArgumentNullException rather than just error(“Wrong parameters specified”).
  • Ability to define and throw custom exceptions, specific to the business domain of D365FO.
  • Ability to catch these custom exceptions in the usual way.
  • Simple syntax for throwing these exceptions.

Throwing .NET exceptions from X++ can be easily done with a little C# class library. We can throw exception objects from C# and we can call C# methods from X++, therefore we can  instantiate an exception, pass it to a C# method and throw it from there.

This is the class in C#:

publicclass ExceptionHelper
{publicstaticvoid ThrowException(Exception ex){throw ex;}}

You could call it from X++ like this:

ExceptionHelper::ThrowException(new ArgumentNullException("_name");

While this works, it doesn’t look natural. I wanted something similar to throw error(“…”). We can’t throw exception objects with throw keyword in X++, but we can do this:

throw exception(new ArgumentNullException("_name"));

exception() is a global function calling the exception helper. It’s implemented in an extension of Global class:

[ExtensionOf(classStr(Global))]finalstaticclass Global_ManagedExceptions_Extension
{publicstatic Exception exception(System.Exception _ex){
        Goshoom.DynamicsAX.ExceptionHelper::ThrowException(_ex);
        // The return statement is never called because an exception is thrown above,// but it makes the method compatible with the throw statement.return Exception::Error;
    }}

The fact that it returns Exception::Error makes it usable in the throw statement. Calling just exception(…) has the same effect as throw exception(…), but the latter is nicely consistent with throw error(…).

When we can throw exception objects, why should we limit ourselves to existing exception classes? We can easily define our own, specific to our needs in D365FO.

For demonstration, I’ve implemented FieldEmptyException, where you can provide information about the field and the record in question. Later you can use this information for logging, for highlighting failing records or anything you like.

For example, here I’m checking if a record has a value in the Email field and I throw a FieldEmptyException if not.

SysUserInfo user = ...
 
if(!user.Email){throw exception(new FieldEmptyException(fieldStr(SysUserInfo, Email), user));
}

Then we can catch FieldEmptyException and react to it, instead of catching all errors by the universal class catch (Exception::Error). We also have all details available when we catch the exception, as demonstrated here:

This infolog was generated by the following catch clause:

catch (fieldEmptyEx){if(fieldEmptyEx.Record){setPrefix("We can log all these details:");
        info(strFmt("Exception type: %1", fieldEmptyEx.GetType().Name));
        info(strFmt("Message: %1", fieldEmptyEx.Message));
        info(strFmt("Table: %1",tableId2Name(fieldEmptyEx.Record.TableId)));
        info(strFmt("Field: %1", fieldEmptyEx.FieldName));
 
        SysUserInfo user = fieldEmptyEx.Record as SysUserInfo;
        if(user){
            info(strFmt("Data from the table: user ID %1, RecID %2", user.id, user.RecId));
        } 
        info(strFmt("Stack trace: %1", fieldEmptyEx.StackTrace));
    }}

But if you want to use the usual catch (Exception::Error), you can! I’ve implemented FieldEmptyException as a specialization of ErrorException, therefore all logic working with the normal X++ errors still applies. This is important – you can start using these custom exceptions without worrying that they would stop being handled in existing code.

The complete source code (with examples) can be found on GitHub. It’s under MIT license, therefore you can do virtually anything with it, such as modifying it and including it in your commercial, closed-source solutions.

Send email with attachment

$
0
0

Hi,

this is the code I am using to send email with attachment.
I am able to send email without attachment with the below code by commenting the bold lines , but while using the bold lines it gives an exception stating the "clr object could not becreated"  on line 2

public void sendMail()
{
str sender = "abc"mail id of the sender
str recipient = "xyz"; //mulitple recipients can be specified
str cc = "pqr"; // mulitple cc id's can be specified
str subject = "seat master excel file";
str body = "Please find the attachment";
str fileName = @"C:\\Users\\admin\\Desktop\\seat_master.xlsx"; //Location of the attachment file


List toList;
List ccList;
ListEnumerator enumList;
Set permissionSet;
System.Exception exception;

str mailServer;
int mailServerPort;
System.Net.Mail.SmtpClient mailClient;
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo;
System.Net.Mail.MailAddressCollection mailToCollection;
System.Net.Mail.MailAddressCollection mailCCCollection;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
FileIOPermission permission;
;

try
{
toList = strSplit(recipient, ';');
ccList = strSplit(cc, ';');


permission = new FileIOPermission(fileName,'r');
permission.assert();

mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
mailServerPort = SysEmaiLParameters::find(false).SMTPPortNumber;
mailClient = new System.Net.Mail.SmtpClient(mailServer,mailServerPort);

enumList = toList.getEnumerator();
enumList.moveNext();

mailFrom = new System.Net.Mail.MailAddress(sender);
mailTo = new System.Net.Mail.MailAddress(strLTrim(strRTrim(enumList.current())));
mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);

mailToCollection = mailMessage.get_To();
while (enumList.moveNext())
{
mailToCollection.Add(strLTrim(strRTrim(enumList.current())));
}

enumList = ccList.getEnumerator();
mailCCCollection = mailMessage.get_CC();
while (enumList.moveNext())
{
mailCCCollection.Add(strLTrim(strRTrim(enumList.current())));
}

mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
mailMessage.set_Subject(subject);
mailMessage.set_Body(body);

mailAttachementCollection = mailMessage.get_Attachments(); //1
mailAttachment = new System.Net.Mail.Attachment(fileName); //2
mailAttachment.set_Name("seat_master"); //3
mailAttachementCollection.Add(mailAttachment); //4

mailClient.Send(mailMessage);
mailMessage.Dispose();

CodeAccessPermission::revertAssert();

info("Email sent successfully");
}
catch (Exception::CLRError)
{
exception = ClrInterop::getLastException();
while (exception)
{
info(exception.get_Message());
exception = exception.get_InnerException();
}
CodeAccessPermission::revertAssert();
}

}

Batch server Vs Debugging X++ code running on Server

$
0
0

Hi,

We have an AOS server and Batch server separately. This is a development and testing environment. Our batch server is working only when Enable breakpoints to debug x++ running on server is  turned OFF. Enabling this parameter will make AOS restart.

to debug x++ code running on server, I have to turn this ON. for that, I had to stop my colleagues working, save their stuff and enable the parameter which in turn restarts AOS and then i have to do my debugging.

I believe there should be a easier way of handling this?

Lakshmi

Personalization vs development

$
0
0

Hi community,

When it comes to customizing OOTB features of D354 FO, we can do that through development. This is clear to me. But we can also do personalization as an admin and apply it to all the users or users with specific roles. So it is kind of achieving the same goal through two different ways, keeping in mind that  personalization is of course more limited than development. I like personlization because you don't need to pay a developer to do coding, rather an IT admin with few hours of training could technically do some personalization and apply to to all users (or some), So I have the following questions:

1. Can we say that we take always customization as first option if it is not possible, because we have limitations,  then we do development

2. If so how would customization be deployed to other environment? Can we do it also through packages or we have to export them and import them in subsequent environments?

Thanks

Embed word document in Excel

$
0
0

Hi All,

How to embed a word document(.Docx) in excel using x++ code in AX7. I have an excel file and it contains two sheets. In the first sheet, I need to embed the word document using x++ code. Please tell me the ways to achieve this ... We are using the following to edit the word document.

public static void main(Args _args)
    {    
        str comments = null;
        str document = System.IO.Path::GetTempPath()+"New Microsoft Word Document.docx";

        using (WordprocessingDocument wordDoc = WordprocessingDocument::Open(document, true))
        {
            str docText = null;
            using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream()))
            {
                docText = sr.ReadToEnd();
            }

            Regex regexText = new Regex("%1");
            docText = regexText.Replace(docText, "150");

            Regex regexText1 = new Regex("%2");
            docText = regexText1.Replace(docText, "Company Name");
            


            using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode::Create)))
            {
                sw.Write(docText);
            }
        }
    }

I need this word document into the first sheet of my excel.

Thanks in Advance.


Table Index Changes

$
0
0

Model X has around 30 tables that need UniqueIndexes/Alternate/Replacement keys (I don't know why it wasn't done in the first place and I didn't ask). Model X is in the process of being implemented at 3 clients. I made a few related posts:

I have been assigned to fix this. I am capable in making the changes in my development environment. The problem is sync issues when the new version gets deployed at the clients. I understand from the referenced posts that the only thing I need to be worried about on the client side is data that will violate my new indexes.

Nikolaos mentioned that a class needs to be run to fix data. The table's that will be changed are not part of the core of model X, thus they either have no data (yet) and if they do, the data may be deleted.

Thus I assume that the solution to providing a successful deployment of the model X update would mean to make sure that all the table's with index changes have zero records before the update.

To accomplish this I asked for two releases. My plan was to provide a simple button on the parameter form which would clear the tables. But now I have only been given a single release. Thus I am left with two options:

  • Provide code that clears the tables which can be run from outside of AX
  • Ask a consultant to manually delete data before deployment (not practical - I'd leave it as a backup plan)

So the reason for the post is:

  1. I need some assurance that I am on the right track. I am in way over my head. I think am right.
  2. If I need to run a class from outside of AX to clear data.... I need a page to read or just some general direction on how to accomplish this. I have a lot of general coding knowledge (C,C++, Java, recently C#) and I am able to write a class that can be run from cmd. It's just new to me in context of AX and I wouldn't know how to "access" AX from "outside".

Thanks for reading

Please let me know if anything is unclear.

Data Entities are not visible in Data Management Framework

$
0
0

In Data Management Framework there are no Data Entities available. But entities are available in Application Explorer in Visual Studio.

I have tried full Build Models and Database synchronization.

I am using a Dynamics 365 for operations cloud hosted environment.

PFA screenshots as reference.

  

Thank you

How to replace integration done in Ax 2012 RTM using C# classes & web service call, sql .net classes

How to customize a class in "Application suite" (sys)

$
0
0

Hi

How do I customize the code in a class which belongs to "Application suite" (sys). I want to comment a line of code and replace it with a new logic.

I tried creating new model in var and sys but when I customize the class and save it and error is thrown "Unauthorized to modify model <modelname> "

please suggest.

Where batch task is saved before get executed?

$
0
0

I am trying to use BatchJob and BatchTask to make the progress bar for my application. My application built with extensible controls and want to use odata/service to track the progress of job I started and change UI based on that. However I don't know which table batch tasks are saved. I know once the tasks are done batch tasks are saved into the BatchHistory table. If batch tasks are not saved into the table I might have to create similar table just for tracking the progress. 

Viewing all 17532 articles
Browse latest View live


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