Tuesday, April 26, 2011

Best Practice Check execution - Multisite in AX 2009 - Specific Checks - Tables - Inventory dimension fields are handled by multisite activation

When upgrading from an older version to AX 2009, the multisite function is, by default, inactive. Ususally when you activate Multisites in AX 2009, you may have an error message saying:

"The Multisite wizard is not up-to date"

This means that some new InventDim fields have been added to some tables and the wizard cannot run. There are many ways to fix this, but I found that by executing a Best Practice Check is the best way to do this.

On the Microsoft white paper about multisites (http://www.ax-pact.com/downloads/Multisite%20Activation%20White%20Paper%20for%20Microsoft%20Dynamics%20AX%202009%20.pdf) they suggest doing this, but they don't tell you where to run the Best Practices Check from.

To do so follow the next steps:

Tuesday, April 19, 2011

Consume an Currency Exchange Rates Web Service from AX 2009 - WFC

Consuming web services from Ax 2009 is a sort of tricky task when the web service is not DAX 2009 "friendly".


Microsoft published a white paper on how to consume a web service to load currency exchange rates into the ExchRates Tables. The problem is that the web service provider's information is outdated. In addition, this white paper does not really explain the problem the developer will faced when the URL does not have the WSDL definition into it.


For example, in the white paper the web service URL is the following:

Tuesday, March 29, 2011

Lightswitch "How Do I?" Videos - Visual Studio Lightswitch

A few weeks ago I downloaded Visual Studio Lightswitch. I'm still getting to know the application and new features that are offered by Microsoft. You can have a full definition of Visual Studio Lightswitch here:

https://community.altiusconsulting.com/blogs/mikevinson/archive/2010/11/09/microsoft-visual-studio-lightswitch-what-is-it.aspx

I do have to say that the development of business applications has been taken to the next step. I think the most interesting aspect of Visual Studio Lightswitch is that we can now develop apps for the cloud. This is really interesting to me as I'm getting into SharePoint development and I just read that Microsoft will have the Office 365 available really soon.

Anyway the Silverlight team has some interesting tutorials about developing data-centered silverlight apps for the web by using Visual Studio LightSwitch. You can find it here:

http://team.silverlight.net/announcement/announcing-visual-studio-lightswitch-beta-2-is-available/


Also, the MSDN LightSwitch has some easy to understand How Do I videos around Visual Studio LightSwitch here:

http://msdn.microsoft.com/en-us/lightswitch/gg604823

Monday, March 28, 2011

Find AOT classes through X++

Today I needed to implement a job that existed my company's old version of AX into AX 2009. In the Old Axapta I went to Basic > Batch List to find the name of the job and/or the date it was created.

Then I went to the AOT > Data Dictionary > Tables > Batch and I opened the table by using the table browser and I saw that the Class ID for this particular Job was 40144.

Then I created a new job and I wrote the following code:


static void ClassNames(Args _args)
{
    DictClass   dictclass;
    ;
   
    dictclass = new DictClass(40144);
    info(dictclass.name());
}



The info log showed me the name of class that is run by the AX Job. From there I just created a new batch record to run it every night.



Wednesday, March 23, 2011

make friendly URL’s for your SharePoint 2010 site in 4 steps with IIS7 URL Rewrite module

I started developing an Internet facing site with the help of this book : http://www.amazon.com/Professional-SharePoint-Branding-Interface-Programmer/dp/0470584645/ref=sr_1_12?s=books&ie=UTF8&qid=1300888674&sr=1-12#_

However, for me SEO is critical nowadays and this book did not give me any information on how to make my Share Point 2010 Internet facing site URL friendly. Because I'm an ASP.NET developer, I knew that now we have the URL Rewrite module in IIS7 and I wondered if I could apply it to a Share Point site as well.

I found this great post that explains how to achieve Share Point 2010 friendly URL by using the II7 URL Rewrite module.

http://blog.mastykarz.nl/friendly-urls-sharepoint-site-4-steps-iis7-url-rewrite-module/

After following the steps stated in the above link, I was able to produce a friendly URL.

Saturday, March 19, 2011

SQL 2008R2 FULL TEXT INDEX SEARCH SETUP

In Microsoft SQL 2008 R2, the process of setting up full text search is done differently then in prior versions of SQL.


In earlier versions of SQL, we would have to right-click on the table we wanted to have full text index search capabilities by going to Design. Once in the table designer, we would choose Full Text Index and we would set the values in the window that would pop up.


In SQL 2008 R2, however, the process of setting up the full text index search is as follows:


The very first step is to create a new Catalog in our data base as follows (Let's not forget to click on the Data Base we want to setup the Full Text Index Search)


CREATE FULLTEXT CATALOG NameOfCatalog


Execute the stored procedure, which should be really quick and in where we should get a message like this:


Command(s) Completed Successfully


Then we go through the following steps:

Friday, March 18, 2011

SQL Injection: Defense in Depth -

SQL Injection happens when a developer accepts user input that is directly placed into a SQL Statement and doesn't properly filter out dangerous characters. This can allow an attacker to not only steal data from your database, but also modify and delete it.

Certain SQL Servers such as Microsoft SQL Server contain Stored and Extended Procedures (database server functions). If an attacker can obtain access to these Procedures it may be possible to compromise the entire machine.

In addition, attackers commonly insert single qoutes into a URL's query string, or into a forms input field to test for SQL Injection. If an attacker receives an error message like the one below there is a good chance that the application is vulnerable to SQL Injection.


Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the
keyword 'or'



The following article talks about how to prevent SQL Injections. I thought it was pretty comprehensive and has good examples on how to achieve a good strategy to minimize these attacks.

http://www.simple-talk.com/sql/learn-sql-server/sql-injection-defense-in-depth/

You can also learn more about it here http://msdn.microsoft.com/en-us/library/ms161953.aspx

Also, there are a few videos that walk you through some of these issues here http://www.google.com/#q=sql+injections+tutorial&hl=en&sa=X&prmd=ivns&source=univ&tbs=vid:1&tbo=u&ei=DGCDTceeN6WY0QG8r7XkCA&ved=0CEcQqwQ&bav=on.2,or.r_gc.r_pw.&fp=3d8c1b5379a812ef

Thursday, March 17, 2011

Axapta: Validate Access to return value from display method - Ax 2009

I was working on a report today and after compiling it I saw that the compiler gave me some Best Practices errors.

Basically the error said : Validate Access to return value from display method.

Well, the compiler is smart enough to remind us that we need to consider if a specific user should have access to the data that you are returning from the function.

In addition, to check if a user has permissions to a specific field, we can use the hasFieldAccess function. There are other functions we can use as well such as hasMenuItemAccess, hasSecurityKeyAccess amd hasTableAccess.

An example is shown below:


//BP Deviation Documented
display vatNumJournal TaxExemptNum()
{
    if(!hasFieldAccess(tablenum(SalesTable), fieldnum(SalesTable, VatNum)))
        throw error("@SYS57330");

    if (SalesTable.VATNum)
        return SalesTable.VATNum;
    else
        return '';
}

The BP Deviation Documented comment line just above the function is to tell the compiler we have addressed the issue.

Thursday, March 10, 2011

Allowing Users to Copy of a Lost or Sent Quote - Microsoft Dynamics AX 2009

The default functionality of Microsoft Dynamics Ax 2009 does not allow to copy a quote when a quote's status is either Lost, Sent, Confirmed, or Canceled.

Today I was asked to allow the users to copy a quote when its status is Sent or Lost.

To copy a quote go to Sales Quotation Details, choose a record and then go to the header level buttons and click Function > CopyFromAll



The following are the steps to accomplish this very quick:

Email Invoices based on customer setup options - Microsoft Dynamics Ax 2009

Today I had a requirement that said to add a CheckBox control to the Customer Form to decide weather to print or email an invoice automatically.


NOTE: I will no go over the actual logic on how to email the invoice as I have already written a post about it, you can find it here http://axwonders.blogspot.com/2011/02/save-microsoft-dynamics-ax-2009-report_23.html


The following is the new control added to the CustTable form under the setup Tab:





 Now the logic is very simple. If the a customer account has this checkbox checked then set the Document destination value automatically to Email. Otherwise set the value of the control to Printer. In the picture above we can see that this specific customer has the checkbox checked.


Then the expected result will be to see the Document destination value to Email when a sales order record needs to be invoiced or acknowledged.


Please see the following sequence:

Tuesday, March 8, 2011

Languages in AX 2009 - Using a the LanguageTable form for Lookup building- AX 2009

Today I had a requirement to only show the following language across the whole application:
  • en-us
  • fr
  • it
At first I thought to create a custom lookup method as I did for another requirement last month (http://axwonders.blogspot.com/2011/03/filter-activity-form-contact-to-only.html), but then I thought .. Oh my .. this would mean to add a lookup method to several forms across the application, and what about if I need to change something in the future? It was a fact that the scalability of this change will be an issue.

Because the requirement said "Across the application" I decided to modify the LanguageTable form to be shown as a lookup in every instance of the LanguageID across the application.

The following are the steps I took:

WPF Training videos - Thanks Joe Stagner

The following is a list of WPF training videos. I found them extremely useful to what I'm doing right now.

http://www.msjoe.com/2011/03/wpf-3-5-training-videos/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+MSJoe+%28MSJoe%29

Enjoy!

114 windows forms tutorials - Thanks Joe Stagner

The following is a great resource on tutorial for win forms.

http://www.msjoe.com/2011/03/windows-forms-training-videos-114/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+MSJoe+%28MSJoe%29

Thursday, March 3, 2011

Filter the Activity Form contact to only existing records on a Business Relationship by creating a Lookup Dynamically- AX 2009

Today a user came to me and asked me if I would be able to show only the contacts related to a Business Relationship when choosing a contact in the Activity form.


The following is the form:



 The original setup would show all the contacts available table wise. This was a problem for the users as it will take a lot of time for them to find the right contact.

Set the Business Relationship Account in the Activities Form

Yesterday I had a requirement that said to pre-populate the Business Relationship Account in the Activities Form field Business Account upon creation of a new activity.

To do this I modified the InitValue() method within the smmActivities Data Source:

Forms > smmActivities > DataSources > smmActivities > Methods > InitValue


To do it I had to make sure that the element that was calling the form was the smmBusRelTable, then I assigned the element record to my smmBusRelTable variable. Finally, upon checking the validity of the record, I assigned the busRelTable.BusRelAccount to the busRelAccount in the smmActivities table.

The code is as follows:


THE FOLLOWING CODE GOES INTO THE FORM INIT METHOD
if (element.args().dataset() == tablenum(smmBusRelTable))
    {
        busRelTable = element.args().record();
        //businessRelationRange.value(smmBusRelTable.BusRelAccount);
    }

This Goes in the smmActivities data source initvalue().
    if(busRelTable.BusRelAccount)
    {
        smmActivities.smmBusRelAccount = busRelTable.BusRelAccount;
    }

Tuesday, March 1, 2011

Set the MarkupGroup from the SalesCreateQuotation Form - Microsoft Dynamics Ax 2009

Today I had a requirement to automatically set the MarkupGroup at the moment a user creates a new Sales Quote in AX.


In the past the user would have had to do this manually but with the following changes in my code this happens in the background.


The place where we want to change this is in the salesQuotationTable.writeCreateQuotation Method. This method can be accessed from:


SalesCreateQuotation Form > DataSources > SalesQuotationTable > Methods > Write



The code is as follows:

Monday, February 28, 2011

Creating a simple Pager user control with ASP.NET and C#

The following is a simple user control that will display a Pager functionality for any type of web page that deals with large amount of data that need to be segmented in pages.

This is part of a larger project and perhaps in the future I will present the finished project, but for now this user control can help us organize our data with a data list.

  1. Create a new web site project in Visual Studio
  2. Add a new Web User control named Pager.
  3. In Source View (Asp.Net) write the following code
  4. <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs" Inherits="UserControls_Pager" %>
    <p>
    Page
    <asp:Label ID="currentPageLabel" runat="server" />
    of
    <asp:Label ID="howManyPagesLabel" runat="server" />

    <asp:HyperLink ID="previousLink" runat="server">Previous</asp:HyperLink>

    <asp:Repeater ID="pagesRepeater" runat="server">
        <ItemTemplate>
            <asp:HyperLink ID="hyperlink" runat="server" Text='<%#Eval("Page") %>' NavigateUrl='<%#Eval("Url") %>' />
        </ItemTemplate>
    </asp:Repeater>
    <asp:HyperLink ID="nextLink" runat="server">Next</asp:HyperLink>
    </p>

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField() - Microsoft Dynamics AX 2009

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField()

initValue()This method file while creating new record to initialize a value, here I am assigning user id to the userID field.

public void initValue()
{
super();
this.UserId = curuserid();
}

Sunday, February 27, 2011

Schedule a Windows Task to call an ASP.NET web page - ASP.NET - VB.NET, Windows Task Scheduler

The following is how you can schedule a windows task that can call an ASP.NET web page. Usually we want to schedule task from Windows. I have seen lots of questions regarding this in the past.

The cool thing about Windows task is that you can execute custom jobs to be executed in the server without the need of a user to be logged in.

The following code can be used to call ASPX web pages to run a specific job that needs to execute some sort of logic. The script is written in VB.NET, but the web page can be written with C# as the vbscript only is used to create the call from the server to the page.

The steps are as follow:

Friday, February 25, 2011

Get Employee email with X++ - Microsoft Dynamics AX

The new way Microsoft Dynamics AX handles employee records is very different from the prior versions. For example, in AX 3.0 or 4.0 the employee table will have an email for a specific record, so you could just do something like this to retrieve an employee email:

EmplTable::find(emplId).email;

I needed to get the Employee ID for a custom functionality that sends a sales status confirmation email to a contact with copy to the employee that is handling that Sales Order.




In Microsot Dynamics AX 2009, however, the employee's information is handled diferently. For example, the Employee contact information is stored in a table called DirECommunicationAddress, and the Employee's address is stored in the Address table.

Wednesday, February 23, 2011

SalesCreateQuotation - Always set an Address when creating a new Sales Quotation - Microsoft Dynamics AX 2009

I was faced with a very weird problem today at work. When a user goes to Sales Quotations and clicks the New button, he/she gets the SalesCreateQuotation form (Show below). In our implementation of this form, a contact is required. So, the user always has to choose a contact that is related to the business relationship that it is being quoted.

Now, the issue is that when users create a contact, they only set basic data such as email, and more often than not, the address fields are left blank.

Save an Microsoft Dynamics AX 2009 report to a PDF file (Second Part) - Save the file to a network location

In this part of the article we'll continue to build our functionality to save an Axapta report to a PDF format, then save this file to a network location, and then send it as an attachment in outlook.

The firt part of this series in here http://axwonders.blogspot.com/2011/02/save-microsoft-dynamics-ax-2009-report.html

In the prior article I created a job to save an Axapta report to PDF into a local drive ... C:\. In this article, the code from the last article is integrated within the Run() method of a class I created called SalesConfirmReportEmail.

The SalesConfirmReportEmail class gets executed when a a user wants to send and post an Order Acknowledgement on a Sales Order. I will not discuss how the code works from the moment the user clicks ok in the SalesEditLines form, but I will point out the path that the code follows:

So, the user opens the Sales Order form, finds a record, goes to Posting > Acknowledgement , does whatever he/she needs to do and clicks OK.

In my implementation, the user can choose the output for the order confirmation report. This is, in the DocDestination drop down list he/she can choose Preview, Print, and/or Email. In this case the user wants to print the report.

Tuesday, February 22, 2011

Error executing code: The method has been called with an invalid number of parameters. - Microsoft Dynamics AX 2009

When trying to use the COM object to attach a file into Outlook I got the following error message:

Error executing code: The method has been called with an invalid number of parameters.

After setting a breakpoint into the SysInetOutlookMail class AddAttachment method, the code broke in the following line:

_outlookMailAttachments = _outlookMail.Attachments();

Save a Microsoft Dynamics AX 2009 report to a PDF file (First Part)

The following code saves an Axapta report to a PDF file. This is the first article of 3. The next article will show how to save the file into a network share and pass a Sales Order dynamically, and the last part will be about attaching the PDF to an Outlook instance and create a dynamic subject. So, the titles of the three articles will be the same foe exception of the text in parenthesis.

In my case, I'm having a lot of problems saving the file to a network file and then to attach it to Outlook. The code below saves the report to a local palce in your computer.

static void Job10(Args _args)
{
   custConfirmJour     custInvoiceJour;
  SalesFormLetter     salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation,  false);
   PrintJobSettings    printJobSettings = new PrintJobSettings();
   Args                args = new Args();
   boolean             prompt = false;
   boolean             printIt = true;
   ;

    printJobSettings.setTarget(PrintMedium::File);
    printJobSettings.format(PrintFormat::PDF);
    printJobSettings.fileName(@'c:\temp\myfile2.pdf');
  
   salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());

   select firstOnly custInvoiceJour
       where custInvoiceJour.salesid == '18-062467';

   args.record(custInvoiceJour);
   args.caller(salesFormLetter);

   new MenuFunction(menuitemoutputstr(SalesConfirmation), MenuItemType::Output).run(args);

}

Monday, February 21, 2011

Data List Control (.NET) - Create a fully dynamic user control that handles URL links and Css Classes - ASP.NET

A few days ago I wrote a post on how to create a fully dynamic Link class in C# that will return a full query string based on what a user is clicking within a page. In the following example I'll present the table design, Stored Procedure, C# class, CSS Class and ASP.NET user control I'm using to

Invoice Verification - Total Line Calculation from PurchParmTableTotals in PurchEditLine - Microsoft Dynamics AX 2009

Today I had to fulfill the following requirement:
  1. When the user clicks "Invoice Verification" from the Purch Order Form, place the follwing in the PurchEditLines Form
    • Invoice Balance
    • SalesTax
    • Line Discount
    • Balance
Usually you can see these values when clicking the Totals button from the PurchEditLines Form object in AX 2009.




When you clicked the Totals button the PurchParmTableTotals Form gets activated and the PurchTotals class gets instantiated. So I needed to basically replicate what this form is doing to present the values we see above in the PurchEditLines form as show below.

Saturday, February 19, 2011

Create a Link (URL) class for ASP.NET and C#

I was faced with a requirement last week to build a dynamic link generator to manage URL's in a site. The project owner did not want to build the URL in the presentation layer as the site has an ecommerce architecture where there are product categories and products department, which include a category in itself.

Of course, if you think about it, every time that the user clicks on a category or department, the site needs to create a dynamic URL like Catalog.aspx?DepartmentID=1". The Query string will be used to retrieve the value of DepartmentId, which in our example is equal to 1.

Thursday, February 17, 2011

In DCOMCnfg "Run application on this computer" is grayed out for my application on two Windows 7 machines, but it works fine on all other machines

I was having a problem sending an email through outlook in one of the dev machines at work this morning. After reading a few articles about the topic, I eneded up going to the Component Services to edit the Outlook Message Attachment Service component.

Went I got to the window (Start > Administrative tools >

Tuesday, February 15, 2011

Create a Custom Error Page in 4 steps - .NET - ASP.NET - C#

Visual Studio gives us the possibility to handle errors by using many different types of error handling functions. However, we know we need to tell the viewer that something went wrong when the application crashes, and for this we need to implement an Error page.

I remember seeing some custom error pages in the past that were implemented by using a class that will be called after an exception was thrown.

It worked well, but the implementation of an error page can be more efficient and faster by doing the following:

Monday, February 14, 2011

Choose to whom send what type of email from Outlook automatically in Microsoft Dynamics AX 2009

Ax 2009 came with many changes regarding addresses and contacts.

(If you want to learn more from it go here http://www.microsoft.com/downloads/en/details.aspx?FamilyID=052e9dda-667b-42bd-bd13-f8c5aa1bc0f0&displaylang=en)

Now the GAB (Global Address Book) allows you to have a centralized repository of contacts (person and/or organizations), these can be used in many different processes such as Business Relations, Leads, Sales Orders, ect.

Because of this, I came up with an idea to setup a place in the contacts table (and form) where the user can choose to whom send what type of email from Outlook automatically.

Monday, February 7, 2011

SysInfoAction Class - Go to a specific record from the Infolog - Microsoft Dynamics AX 2009

Today I had a requirement that would allow a user to go to a ContactPersonLookup form record from an infolog that would be showed when a user wants to send an email to a contac without an email address.

First I needed to get the ContactPersonId based on the contact's PartyID. The following method takes one parameter (PartyId) and goes trough a simple sql query to get the record I need:

Thursday, February 3, 2011

Inventory Verification - Placing values from PurchParmTotals on PurchEditLines Form in AX 2009


Today I had to fulfill the following requirement:
  1. When the user clicks "Invoice Verification" from the Purch Order Form, place the following in the PurchEditLines Form
    • Invoice Balance
    • SalesTax
    • Line Discount
    • Balance
Usually you can see these values when clicking the Totals button from the PurchEditLines Form object in AX 2009.

Wednesday, February 2, 2011

Great post about Logic and Problem - Solving Skills

The following text is taken from the following web site: http://www.eggheadcafe.com/software/aspnet/29604130/c-algorithms--c-puzzles.aspx


Presuming that you are studying programming, a desire to improve your problem-solving skills and understand logic are excellent goals to have in mind. Almost all of programming is problem-solving, and involves the use of logic.

Free C# books (General) -- Free C# Algorithms Book (Amazing!)

General


Algorithms

Initialize Table Value to a Drop Down List in Sales Quotation Edit Lines - Microsoft Dynamics AX 2009

Today I needed to initialize a bunch of values in the Sales Quotation Edit Lines Form in AX 2009. Basically the form (in Designs) has a Tab Page named Parameters. Within this form you can see the following:



My task was to set the Print Confirmation check box enable property set to false and to set the value of the Reason drop down list to "New Sales Order". A best practice for AX 2009 is to create this logic directly in the Form methods or Tables, rather than setting fields through MorphX.

Tuesday, February 1, 2011

Set a Date Value to a Date Filed in AX 2009 with X++

I was faced with a requirement that I needed to set a date value to a custom date Filed in AX 2009 with X++, with the Purch Order Creation Date.

I knew that the following could work:

...
FormControl control;
;
control = element.design().controlName('PurchTable_OrderDate'));
control.Text = DateTimeUtil::ToStr(purchTable_ds.Object(fieldnum(PurchTable, CretationDateTime);
...

However, I wanted to create a solution that would not be so dependant on the Form object as this can bring headaches when upgrading. Therefore, I decided to do it at the data source level as follow:

purchTable_ds.object(fieldnum(PurchTable, OrderDate)).setValue(DateTimeUtil::date(purchTable.createdDateTime));

The above code is far more efficient and it needs to be set either in the Data Source (PurchTable) of the PurchTable form Init() or Active() method.

 

Wednesday, January 26, 2011

MS Dynamics AX - SharePoint - .NET: UTCDateTime to Date Conversion (Error Operand type...

MS Dynamics AX - SharePoint - .NET: UTCDateTime to Date Conversion (Error Operand type...: "The utcdatetime data type is intrinsic to X++. It combines date and timeOfDay types into one type. A utcdatetime variable also holds time zo..."

UTCDateTime to Date Conversion (Error Operand types are not compatible with the operator)

The utcdatetime data type is intrinsic to X++. It combines date and timeOfDay types into one type. A utcdatetime variable also holds time zone information, though this information is not accessible to X++ code.

I wanted to fill the SalesQuotationTable.QuotationDate (Custom field from older version - Type Date) field in all my quotes,

Tuesday, January 25, 2011

Super() ... When design gets in the way : (

The following is the definition from this web site http://msdn.microsoft.com/en-us/library/dd261515.aspx

The super keyword is used in a derived class to access the same method on its base class.
void method2()
{
;
// Call method2 method
// on the base class.
super();
}
I was having a problem when trying to write a new Quote into SalesQuotationTable this morning. For some reason every time I wanted to create a new quote (by clicking OK), a warning message would come up saying "The field Business Relation has to be filled".

Ok, no problem, the above told me that probably the last developer set the field to be mandatory or there should have been something in the code that was checking for this field to be filled.

The strange thing was that the field wasn't mandatory and depending from where the quote was coming, the field would not be needed. For example, if the Business Relation account was converted to a Customer, the business relation does not show in the SalesCreationQuotation Form. Instead we show the Customer Account and viceversa.

This is the code that decides that:

prospect          = (accountType.selection() == smmQuotationAccountType::BusRelAccount) ? true : false;
    if (prospect)
    {
        groupBussinessRelation.visible(true);
        groupCustomerAccount.visible(false);
    }
    else
    {
        groupBussinessRelation.visible(false);
        groupCustomerAccount.visible(true);
    }
Now, with this information I started suspecting about my classes calling base classes methods that I was not aware of, and I took a close look to the Super calls.

So from the ValidateWrite() method in the SalesCreationQuote Form, the Super() would call the ValidateWrite() method in the SalesQuotationTable. Now, I discovered that the ValidateWrite() method in the SalesQuotationTable Super() call was always directed to a class to show an info log.

After reading this blog http://daxguy.blogspot.com/2006/12/super.html I decided to suppress the Super() call from the ValidateWrite() method in the SalesQuotationTable and I was able to write to the SalesQuotationTable with no problem.

I tested it with records being called from the Business Relation Form, or straight from the SalesQuotationDetails and choosing a new record manually.

: )

Table [] called without buffer

I was  working on AX 2009 CRM Module creating a new Lead. Everything worked fine but the Qualifying Process Drop Down List (and button).

Basically I was trying to develop a customization around the form, and I needed to understand the Stages process , but I was being unable to get that far as I couldn't select anything from the Qualifying Process (it was empty), and because of that reason both the Qualifying Process and Stages button were grayed out.

Anyway, I right clicked the Qualifying Process Drop Down List (on the Grid) and then went to "Go To Main Table" and I got an error saying "No object specified on menu item Hierarchy". Mhhhhhhhhhhh....

Then reading some blogs about the error I learned that I needed to create a new menu item named Hierarchy (The same as the Table/Form) pointing to the Hierarchy form. When I went back to the Qualifying Process Drop Down Menu again and clicked "Go To Main Table" I got the error "Called without valid buffer"

What does this error mean?

Well, based on Microsoft the error is caused due to the form requires that it be called from something else, and the other object will pass in a record. 

Response from Microsoft:
If you examin the init() method of the Hierarchy form, you will see the following code:

 if (isTemplate)
    {
        projActivityLink = false;
    }
    else
    {
        if (element.args().dataset() != tablenum(Hierarchy))
        {
            // Called without active buffer
            throw error("@SYS18626");
        }
    }


Notice the if statement after the else.  This is testing to see if the record being passed in comes from the Hierarchy table.  If this fails, it throws the error. 
Since I created a menu item and did not pass in a table buffer from the Hierarchy table, this causes the error message to occur.

The problem is that I haven't resolved the problem yet as I decided to just keep working on other customization for now on. I will post the answer when I get it. Of course if you happen to know the answer, it would be great if you could share it with me.

Friday, January 21, 2011

DeliveryCountry Field in 3.0

The field from smmQuotationTable.DeliveryCountry (AX 3.5) was changed to:

SalesQuotationTable.DeliveryCountryRegionId

More info here http://schunk.dk/DocWeb2009/Tables/SalesQuotationTable.html

LINQ Left Left Outer Join

I wrote an application for my company which required me to use data coming from an external application (Microsoft Dynamics AX). This is actually a view that is generated by a job every night.

The table contains all the branches information (Name, Address, Country, ID, ect).

Wednesday, January 19, 2011

internal size of the records in your joined SELECT statement is 25006 bytes... Problem and Resolution

While testing the AX 2009 CRM module today I clicked Update > Quotation button and I got the following error:

The total, internal size of the records in your joined SELECT statement is 25006 bytes, but Microsoft Dynamics is by default performance-tuned not to exceed 24576 bytes.

This means that the Max Buffer Size in the Dynamics AX Server Configuration Utility is either too small or blank. In my case was blank.

To Resolve the issue I opened the Ax Server Configuration Utility (Start > Administrative Tools > Microsoft Dynamics 2009 Server Configuration) and I created a new configuration pointing to the same AOS instance.

Under the tab named Database Tuning I set the filed named Maximum Buffer Size to 70570 and saved the configuration.

When I opened AX 2009 again and I replicated the action (explained above) everything worked fine.

Create a new Number Sequence for a Lead ID in AX 2009 CRM

I experienced something extrange today while setting up AX 2009 CRM module. My organization did several modifications in the prior version of AX (3.0).

While testing the lead functionality I noticed that the user has to come up with an ID (write an ID ... weird). So I thought it was because of the customizations made to the systems in prior versions, but then I realized that the 3.0 version did not have leads.

After doing some research, I realized that the way to do it is the following:

Go to CRM - Setup - Parameters - Number Sequence (Tab) >

Look for the Lead Id name under the Reference Column. In my case this was empty. So I went to:

Basic - Setup - Number Sequences - Number Sequences - and I created a new record like the:

Number Sequence Code: CRM_12 
Name: CRM Lead ID 
Smallest: 1
Largest: 999999 
Next: 1 
Format: L-######## 

Then I went back to CRM - Setup - Parameters - Number Sequence (Tab), and assigned the newly created number sequence to the Lead ID and done.

AX 2009 Address Global Book - : (

In Dynamics AX2009, the Global Address Book is a repository for every Person OR Organization that your organization comes into contact with. 

When you create a customer, vendor, employee, business relation, contact or competitor, a record is automatically created in the global address book.

However, only certain common fields are shared:

•    Name
•    Address
•    Communicaitions (Telephone, fax, etc)
•    Number of employees
•    Organization number
•    Category

Other data will not be synchronized.

SharePoint Query String URL Filter Web Part

I created an application using WSP in Visual Studio 2008. This application is template to record tasks that are assigned to different regional managers within our organization.

The CEO of the organization will go over these tasks every Monday and plan accordingly. So he needed to have a quick way to see all the tasks for all the locations at once. We decided to create a report using conventional reporting tools.

One of the challenges we faced was that we needed to pass a parameter to the report server, which is integrated within SharePoint. However, we still needed to create a SSRS Web Part, which would not take an URL query string. Additionally, the SSRS Web Part was created in a new site within the SharePoint organization site.

Anyway, I found the following article that helped me resolved this issue by implementing a Query String Web Part file into my environment. So, when the user clicks a button called "View Report", a parameter is sent through a Response.Redirect() from my application code behind language (C#) to the new Sharepoint Site where the SSRS web part is. The parameter is then capture by the Query String Web Part (This web part is on the same site and "page" that the SSRS web part is) and passed internally to the SSRS report server web part.

For more information on how to use the web part please go to the following link:

http://blog.seancleaver.com/sean_cleaver/2008/01/sharepoint-quer.html

Tuesday, January 18, 2011

Microsoft Dynamics AX CRM - Business Relationships

While working in the migration from MS Dyanmics AX 3.0 to AX 2009, I noticed that in the CRM module the Business Relations has some new cool features:

  1. The contacts list is right below the business relations. In AX 3.0 one needed to go to a different screen.
  2. When creating a new prospect that is not link to neither a Customer or Vendor account, AX will automatically assign the employee ID related to the business relation from the DirPartyTable.
Also, what caught my attention was the fact that the Bussines Relation form has 13 more datasets that the 3.0 version as now there are common tables that share id's, such as the address and emplTable for example.

Installing SharePoint Foundation on Windows 7 X64

I just installed Sharepoint Foundation in Windows 7 X64. I had to follow this article (http://msdn.microsoft.com/en-us/library/ee554869.aspx) very closely to get it to work. Specially when it comes to installing the hot fixes, one MUST do it. For example I have SQL Server 2008 R2 and I thought the SQL server hot fixes would not apply to my case. Wrong!.

Also, for some reason the installation of the Windows Identity Foundation went wrong the first time I did it without me knowing about it and the wizard did not run. So, I uninstalled the whole thing (Sharepoint Foundation installation), then I installed all the hot fixes for it and installed Sharepoint again.

The setup run with no errors and the configuration wizard run with no errors, so in my eyes it worked, but my site was blank. I went to the IIS and under Authentication for Sharepoint Central Administration and the Sharepoint sites, I changed the Basic Authentication from Disabled to Enabled.

However, this didn't not fix the problem. In fact, I would have to enter credentials, so I assumed that it would be ok to enter my domain credentials (windows 7 credentials).

This created yet another error related to the IIS worker process crashing. I went to the event viewer and I saw this:

Faulting application name: w3wp.exe, version: 7.5.7600.16385, time stamp: 0x4a5bd0eb
Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdfe0
Exception code: 0xe0434f4d
Fault offset: 0x000000000000aa7d
Faulting process id: 0×1634
Faulting application start time: 0x01cbb754642bc4c9
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: a308a667-2347-11e0-ba6c-002318baaa4f


I researched the error and nothing helped me solved the problem. Then, I light of wisdom came into my mind, Application Pools!

So I went to IIS and to the application pools for the SP central admin and the sharepoint site and I changed the identity from NetworkService to LocalService.

I did reset IIS, entered my credentials and wuala!