Wednesday, March 3, 2010

How to Get Parent Window in Jquery



Consider the following script:

$("#btn").click(function(){ 


        window.opener.$("#chk_accept-terms").attr("checked","checked"); 
        window.close(); 




}); 

The above code first check the check box present on parent window ( window that open the popup or child window) and  then close the child window.

How to perform some functionality on form OnLoad event

When creating new task we want to perform following two activities.





  • Change the default duration from 30 minutes to blank.
  • Auto-populate today’s date into the Due Date field.
These two changes might seem simple at first, but digging deeper into the details of these two fields reveals some obstacles to make these changes. Because the Duration field looks like a picklist field, you would expect to be able to just change the default value by editing the Duration attribute of the Task entity. However, even though the Duration field appears to be a picklist, it is actually a special field used on various activities in Microsoft CRM. For these special fields, you can not set a default value (or add picklist values) like you can for normal picklist fields.



In addition to the Duration field nuance, DateTime attribute data types do not have a default value. Since the Due Date field uses the DateTime data type, we can’t use the attribute editor to specify today’s date as the default value in the Due Date field.
Despite the two problems we just outlined, we can easily meet the customer’s request to change the default task form by leveraging the form OnLoad event of the task entity’s form.
To accomplish this we will add a simple script to the form OnLoad event and Microsoft CRM will run our script everytime a user opens the task form. When it runs, our script will programmatically change the value of the Duration and Due Date fields to the values we specify
Procedure: Using the Form OnLoad Event to Default Task Duration and Due Date
1.   Navigate to Settings -> Customization -> Customize Entities. Double click the Task entity. The  
     entity editor will appear.
2.  Click Forms and Views. Double click Form. The form editor for the task entity will appear.

3.   Click Form Properties and the editor window will appear. From here, you see that you can choose to add a script to the  form OnLoad or OnSave event.



4.   Select OnLoad and click Edit. The Event Detail Properties window will appear. In this window, enter the following code:

var CRM_FORM_TYPE_CREATE = 1;          
 var CRM_FORM_TYPE_UPDATE = 2;
           
 switch (crmForm.FormType)
  {
   case CRM_FORM_TYPE_CREATE:
    crmForm.all.actualdurationminutes.DataValue = null;
    crmForm.all.scheduledend.DataValue = new Date();
    break;
  
   case CRM_FORM_TYPE_UPDATE:
    // do nothing
    break;
  }
  

A quick review of this code shows that Microsoft CRM allows us to programmatically set the values on the form using
javascript. This code sets the actualdurationminutes field (the schema name for Duration) to NULL, which means the same
as blank. It also sets the scheduledend field (the schema name for Due Date) to today’s date using the javascript Date( )
function. The OnLoad event will run this script everytime a user opens a form, but remember we only want to set the default
values when users create a new task. Therefore, we added the cases so that our script only runs for the form type of 1.
Microsoft CRM assigns a form type value to each form (1-Create, 2-Update, 3-Read Only, etc.) so that you can tie this
information into your scripts just like we needed in this example. In this script, if the form type is 2 that indicates
it is an update form so we don’t alter the Due Date and Duration field values.

5.  After you enter the code, click the Event is enabled checkbox. This box indicates whether or not Microsoft CRM should run
your script when it fires the OnLoad event. The screen should look like this:







6.  Next we’ll setup the Dependencies related to our code to make sure that no one accidentally removes the Duration or
     Due Date field from the task form (because our script would generate an error if those fields were missing).
     Click the Dependencies tab.

7.  You’ll see two columns: Available Fields and Dependent Fields. The Available Fields column lists all of the fields that  
     appear on the task form. To make Due Date and Duration Dependent Fields, select those values in the left column
     and then click the ">>" button. Microsoft CRM will move those fields into the Dependent Fields column.





.
     8.   Click Ok. You should be back on the task form editor now.
9.   Next we want to use the form preview feature to test the code we just added. Before you try preview, make sure you
      save the changes you made by clicking the Save button.



10.  If you try testing your script on the update form using Preview -> Update Form, you’ll see that the Due Date field does not default to today’s date just like we expect (because our script only runs on Create forms). However, you might notice
that the Duration field appears blank. When you use the Update Form preview Microsoft CRM shows you an update of a blank record so it will always show picklists as blank, just like it does for the Priority picklist on the task form. So the
script ran correctly, but the fact that Microsoft CRM shows an update of a blank record might causes some little nuances
like the blank picklists.

Now that you tested the script and it works correctly, you’re ready to publish. To publish the task entity, return to the
entity editor and click Actions -> Publish in the top tool bar.

That’s it, you’re done!



This example showed how you to tap into the form OnLoad event to manipulate field values before users see the form. Even if you didn’t understand the syntax of this code example, you should understand the concepts of how you can highly customize your forms by adding custom scripts that tie into Microsoft CRM form events.
Of course, this example just shows a very simple tweak to the task form, but you can get very creative with additional custom code and the powerful programming model of Microsoft CRM 4.0.


    

XRM


XRM is the official positioning of the platform components underlying Microsoft Dynamics CRM. While the "C" is equal to customer in CRM, "X" is equal to ANY relationship that needs to be managed, such as vendors, employees, prospects, dealers, as well as other types of business relationships including properties, assets, projects, grants, legislation, etc. The flexibility of the XRM platform components enables it to be leveraged in a wide variety of ways by many different organizations.

Why XRM?

Most organizations meet their business process automation needs through the development of custom applications or the acquisition of packaged applications. Often times these solutions do not fulfill every business requirement. Custom applications can be extremely expensive to develop and maintain. Research has identified that it will cost a company from seven to ten times more to develop a particular functionality than to purchase comparable functionality. The costs and risks associated with developing highly specialized line-of-business are truly prohibitive. Packaged applications, while easy to deploy, do not fit the business and can be very difficult to change once they are deployed. XRM offers an alternative and the best of both worlds; it accelerates the creation of LOB applications, and it makes it easy to modify existing applications in response to ever-changing business needs.
XRM can help enterprise organizations bridge the gap between packaged and custom applications. Short and long term benefits make XRM a feasible strategic alternative. With XRM the IT Department delivers speed, business fit and business agility. In the short term the IT Department can rapidly respond to a request for an application, on-time and on-budget.
And over time, the IT Department can deliver multiple business applications, all built on a common platform, helping them meet diverse and ever changing business needs across the organization while minimizing the time and costs associated with infrastructure, maintenance, support, integration, modifications and customizations.

Benefits of XRM

XRM is a business application platform layer that sits on top of – and leverages the power of – the Microsoft Application Platform technology building blocks (Windows, SQL Server, .NET, and Office) and is designed to significantly accelerate the creation of enterprise-class relational business applications by providing IT professionals with reusable ‘application services’ that can be rapidly adapted to fit the unique needs of users and businesses through point & click. Key value areas include:
  • Familiar Microsoft technologies give end-users a consistent experience across all applications (Office/Outlook) and provide IT professionals with technology they know (SQL Server, Windows, .NET).
  • Power of choice ensures organizations get and use XRM the way they need it. Whether it be on-premise or on-demand, subscription or license, Outlook or web, the power of choice ensures it fits customers environment and budget.
  • Enterprise-class capabilities through highly scalable multi-tenancy for efficient management of multiple large-scale applications in a single environment
  • Point & click customization allows each application to be completely built (relational data model, process automation, user experience…) and maintained through a point & click interface.

Tuesday, March 2, 2010

How to change new_ prefix to your OWN

Navigate to Settings -> Administration -> System Settings and you'll get this dialog:




In this dialog you can see the Prefix text box. Enter your own prefix to replace the default  "new" prefix.

ISV.config in CRM 4.0

I recently wanted to add a button in CRM 4.0:

In CRM 4.0 there is no ISV.config in the _resources folder like CRM 3.0. CRM 4.0 is multi-tennant and each tennant can have a unique isv.config. So, You can find this file in  "export customization" view.
You can get this file by following the instructions below.

1.  Export current ISV config: Settings -> Customization -> Export Customizations and then select ISV Config and  
     press Export Selected Customizations.
2.  Save .zip file and Edit .xml file inside it.

Backup this file so that if you will do some thing wrong and will get some errors, then you can revert back to this working file.

Now add your customization ( Please see the SDK for more info). Save the file and import back it to the CRM 4.0 by following the instructions below.

3.  Import modified file from Settings -> Customization -> Import Customizations
4.   See your customizations!

if your UI customizations aren't showing up in the UI? Please see  my previous post where i gave the URL to resolve this problem.

An introduction to the $(document).ready() function and explaining how important it is.


This is the first thing to learn about jQuery: If you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.
 $(document).ready(function() {
   // put all your jQuery goodness in here.
 });
The $(document).ready() function has a ton of advantages over other ways of getting events to work. First of all, you don't have to put any "behavioral" markup in the HTML. You can separate all of your JavaScript/jQuery into a separate file where it's easier to maintain and where it can stay out of the way of the content. I never did like seeing all those "javascript:void()" messages in the status bar when I would hover over a link. That's what happens when you attach the event directly inside an tag.On some pages that use traditional JavaScript, you'll see an "onload" attribute in the tag. The problem with this is that it's limited to only one function. Oh yeah, and it adds "behavioral" markup to the content again. Jeremy Keith's excellent book, DOM Scripting, showed me how to create an addLoadEvent function to a separate JavaScript file that allows for multiple functions to be loaded inside it. But it requires a fair amount of code for something that should be rather straightforward. Also, it triggers those events when the window loads, which leads me to another advantage of $(document).ready().
With $(document).ready(), you can get your events to load or fire or whatever you want them to do before the window loads. Everything that you stick inside its brackets is ready to go at the earliest possible moment — as soon as the DOM is registered by the browser, which allows for some nice hiding and showing effects and other stuff immediately when the user first sees the page elements.

Learn JQuery

Click the link: http://docs.jquery.com/Main_Page

How to Edit Independent Software Vendor (ISV).

For information please visit link: http://blogs.msdn.com/jannemattila/archive/2008/01/10/crm-4-0-and-isv-config-modifications.aspx