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: