Friday, February 27, 2009

List of Events available to trap in Scripts when saving a Dynamics CRM Form

CRM 3.0 has limited event detection made available using scripting. However It is now possible to detect which user action was performed to Save the form using the event.Mode property in the OnSave event.

You can gain more detailed information about the user actions in the OnSave event by referencing the event.Mode values. These values represent the buttons clicked by the user to save the record.

The following event modes are supported:

EntityEvent ModeValue
AllSave1
AllSave and Close2
AllSave and New59
Task, Phone Call, Letter, Fax, AppointmentSave as Completed58
AllDeactivate5
AllReactivate6
Alluser-owned entities Assign 47
E-MailSend7
LeadQualify 16
LeadDisqualify15

By checking the value of event.mode we can find out which button user has clicked and based on this take further action.

To cancel the Save operation event simply use the script below:
event.returnValue = false;

Wednesday, February 25, 2009

Add SRS report to CRM Form

In course of implementation of Dynamics CRM, a number of clients have asked us to display reports designed using Sql Reporting Services (SRS) within CRM as a tab or may be as a option to the Main Menu. This helps the user to quickly check reporting. I have described a simple way to achieve this in Dynamics CRM
This can be done using following steps.
- Create SRS report.
- Get the rdl file from the project.
- Open IE and type
http://servername/reports without port number as shown below



- Click on “Upload File” each time for each of the “.rdl” files which we are sending you with this mail and then click OK.
- Do not change its “Name” attribute, as shown below.


- Open IE and type
http://servername/reportserver without port number
- Here you will find the report with the same name as of above.
- Click on the page which will open the report in IE.


- Copy this url and use where ever you want i.e. in IFrame or aspx page which would look like:

"http://servername/reportserver?%2fcrmorg1_MSCRM%TestReport&rs:Command=Render"
- Just pass this url and you can see the reports.

You can also append "&rc:Toolbar=false" to the above url if you dont want the toolbar to be seen in the reports(refer the above image below the address bar) and "&rs:ClearSession=true" to ensure that everytime you can see fresh reports.So that the modified url will look like:

"http://servername/reportserver?%2fcrmorg1_MSCRM%TestReport&rs:Command=Render&rc:Toolbar=false&rs:ClearSession=true">

With this you can now design a dashboard report in CRM and have it added as item under Workplace and set it as the Default item to be displayed. So each time you login you see the dashboard.

Tuesday, February 24, 2009

Bulk Edit records of any entity in CRM

We can easily edit a record in crm. But what if we need to edit a field of all records with same value. So here, Instead of opening records one by one and editing it, we can also use Bulk edit feature which edits that field in one go for all records.

For some records like account,contact ,lead, Product etc, there is already an in-built feature for bulk editing these records.

Below we have explained how to bulk edit the account records :


  1. Select all the records for which you need to edit fields in bulk. We have selected all the account records as shown in the screen below:


2. Now go to More actions and click on edit.



3. Then you will get the window as shown in the screen below. Here, you can edit any field which will be applied to all the selected records. We have edited the account name.




4. Only when you save this form, you will find that all the selected records have been edited with that value. Here we edited account name and all the account names of selected records will be test as shown in the screen below :




This is how Bulk edit of account entity works.

Note :- CRM does not support bulk edit for all entities like Activities ,SalesOrder.

But, if you want to Bulk edit records of Activities ,salesorder which are not supported by CRM then we can do this also.

For this, you will have to write a JavaScript on “ISV Button” and place that button on the particular entity where bulk edit feature is desired.

In that script we have to call a function which is :

“doAction('crmGrid', 'entitytypecode', 'bulkedit')”

Below is a code for adding a button for bulk editing Appointment records which will be added in the isv.config :

//Start of Script

<Entity name="activitypointer">//You can change the entity name

<Grid>

<MenuBar>

<Buttons>

<Button Icon="/_imgs/ico_18_debug.gif" JavaScript="doAction('crmGrid', '4201', 'bulkedit');" Client="Web">

//”4201” is the entity type code of Appointment

<Titles>

<Title LCID="1033" Text="Bulk Edit" />

</Titles>

<ToolTips>

<ToolTip LCID="1033" Text="Bulk Edit." />

</ToolTips>

</Button>

</Buttons>

</MenuBar>

</Grid>

</Entity>

//End of Script


We have to only change the entitytypecode according to the entities required for bulk edit.

For example : If we want to bulk edit “Salesorder” then we have to write doAction function as follows:

“doAction('crmGrid', '1088', 'bulkedit')” where "1088" is the entitytypecode of salesorder entity.
We can also bulk edit the records for entities like phonecall,email etc by changing their respective entitytype codes in the doAction function.

Friday, February 20, 2009

Automatically resize the IFRAME to adjust to the Form size

If you need to show an external page within CRM, you need to provide the URL to the IFRAME in CRM. You will notice that it would not display scrollbars to scroll through the entire web page being displayed in the IFRAME. So it is advised that we create a custom page and add an IFRAME within a "DIV" tag. This helps in bringing up the Scroll bars to allow users to navigate through the entire page.

But there is still a glitch. If you happen to resize the form on which the IFRAME has been added, you will find that the IFRAME does not automatically resize itself according to the form.

Here is the script that we used to achieve this.

Here we try to resize the two IFRAMES ('IFRAME_ActivityShow' and 'IFRAME_ReportShow') that were added on the CRM form.

Add the below function in the custom page on which the IFRAME has been originally placed


function calcHeightWidth()

{

var main_height = null;

var main_width = null;

var height = null;

var width = null;



// for all except Explorer

if (self.innerHeight) {

main_height = self.innerHeight;

main_width = self.innerWidth;

// Explorer 6 Strict Mode

} else if (document.documentElement

&& document.documentElement.clientHeight) {

main_width = document.documentElement.clientWidth;

main_height = document.documentElement.clientHeight;

// other Explorers

} else if (document.body) {

main_height = document.body.clientHeight;

main_width = document.body.clientWidth;

}



height = main_height * (3/4) + 'px';

width = main_width * (1/2) + 'px';



//change the height of the iframe

document.getElementById('IFRAME_ActivityShow').style.height=height;

document.getElementById('IFRAME_ActivityShow').style.width=width;

document.getElementById('IFRAME_ReportShow').style.height=height;

document.getElementById('IFRAME_ReportShow').style.width=width;

}


We need to attach this function to the IFRAME in the page load event of the custom page.

if (!Page.IsPostBack)
{
IFRAME_ActivityShow.Attributes.Add("onload","javascript:calcHeightWidth()");

}

Hope this helps others too!

Wednesday, February 18, 2009

Design a workflow for performing repetitive tasks

Sometimes, there is a need to perform a particular task or action repetitively over a period of time. We were in a need to create a task activity after every 2 days against an account.

This can be done by creating child workflow and call it from the parent workflow. The child workflow would peform the actual job and the parent will call this child recurrsively.

Here are the steps to get this done:
  1. Create a workflow for required entity (For eg: account) with following triggers
    - On demand
    - As a child workflow
    - Record is created
  2. Set the scope of the Workflow as appropriate (For eg: organization)
  3. Now the structure of workflow will be as follows:

First is wait condition which says, wait for 2 days after the execution of this workflow. This condition is as shown below:

After this condition is fulfilled, a task is created and then again child workflow is started which is the same workflow created above (i.e. test recurring). So, the workflow runs recursively and creates a task after every 2 days.

Monday, February 16, 2009

Shortcut to open any record in CRM

There are a couple of generic urls that would let you open any type of record in CRM

  • If you need to open any type of record but don't know the URL. No worries just specify object type code (you can get object type code from CRM SDK under section" Entity Type Codes") and ID it will open your record. (Note that the parameter names are case sensitive here)

http://server:port/organization/CRMReports/viewer/drillopen.aspx?ID=objectid&OTC=objecttypecode

  • To open a record in ReadOnly mode

http://server:port/organization/_forms/readonly/readonly.aspx?objTypeCode=objecttypecode&id=objectid

You can call these from anywhere in CRM and it will identify the entity and open the relevant entity form. This does away the need or specifying url specific to the entity.

Shortcut to create activities for an account or contact

CRM Forms already have a button to quickly send an email. The "Follow up" button allows you to quickly create activities, however it does not show up the entire activity form.
If you instead wanted a way to create a task or some other activity and want the activity form to show-up without navigating to the Activities pane and click on New and select the appropriate entity, here is the code that will help


  • Send Email: locAddActTo(4202); // where 4202 = objecttypecode

  • Create Task: locAddActTo(4212)

The entire list of ObjectTypeCode for all entities in CRM can be found in the SDK

Friday, February 13, 2009

Shortcut to Add notes and attachments

You need to navigate to the Notes tab each time you need to add a note. Also the shortcut to add a quick note in CRM does not show up the note form that allows to fill in all details including subject and attachment in one go. If you want to add all information to the note it would involve atleast a couple or more of clicks to get all done.
You can add convenient shortcuts to add notes without having to navigate to the Notes tab and save a few clicks.


  • add a note : locAddObjTo(5); This will open up the new note form

  • attach a file : locAddFileTo(5); This will bring up the attach file form.

Shortcut to add new records for related entities

CRM navigation especially for adding related entities like activities/Contact/Quote Products etc is quite tedious and time consuming. You can add a shortcut for most of these on the main form and save quite a few clicks in the process.

First decide for which entity you need to add "Shortcut" button like if I need to create shortcut for "Existing Order Products" on order form.

So you need to create first URL. You can find URL by pressing CTRL+N on a form for which you need to create shortcut.


URL for adding existing order product:

/orgname/sfa/salesorderdetail/edit.aspx?_CreateFromType=&_CreateFromId=&locked=0

URL for adding write-in order product:

/orgname/sfa/salesorderdetail/edit.aspx?_CreateFromType=&_CreateFromId=&isproductoverridden=1

  • Every entity has an ObjectTypeCode associated with it. You can get the complete list in the SDK.

  • ObjectId above refers to the current entity id for which the child needs to be added.


You can add ISV button like shown in below on the Order entity,

<Button Icon="/_imgs/ico_18_1089.gif" JavaScript="window.open('/' + ORG_UNIQUE_NAME + '/sfa/salesorderdetail/edit.aspx?_CreateFromType=' + crmForm.ObjectTypeCode + '&amp;_CreateFromId=' + crmForm.ObjectId + '&amp;locked=0','my_ex_item_window','width=900,height=600,toolbar=no,status=yes,scrollbars=yes,resizable=yes')" PassParams="0" WinParams="" WinMode="0">

<Titles>

<Title LCID="1033" Text="Existing Item" />

</Titles>

<ToolTips>

<ToolTip LCID="1033" Text="Add existing order product" />

</ToolTips>

</Button>

Wednesday, February 11, 2009

Product/Inventory Kits in Dynamics CRM and its utilization

Dynamics CRM provides for setting up of "Kits". Kits are basically a group of items that are sold together always. Just like you can associate substitute items with a product, it is possible to associate all products that make up the Kit. The "Kit Products" option is only available for "Kit" type of items.

While this is not directly made available as a type of product like "Sales
Inventory", "Services" etc, it can be found as an option under More Actions
--> Convert to Kit


Once a product is converted to Kit it is possible to convert it back to "Product". A similar option as above called "Convert to Product" is available for Kit Products.

The Kit product is available just as any other product for selection in Opportunities/Quotes/Orders/Products.



One feature though missing and would truly help was if there was a way to determine the price of the Kit based on the price of its components. And if it were possible to explode the kit and have the individual components listed on the Quote (if someone needed to list out the components being supplied in the kit).

To overcome the above shortcoming of updating the price of the Kit based on the price of its components we proposed the following solution to one of our clients.

1. Write a Post-Update plugin on the Price List Item entity.
2. The plugin would read the Product, Unit and Price List from the Price list item.
3. With the Product and Price List in hand, search if this Product is a part of kit and if so, re-calculate the price of the Parent Kit product.


The following messages of the SDK would be helpful when dealing with Kits
* ConvertKitToProductRequest
* ConvertProductToKitRequest
* AddProductToKitRequest
* RemoveProductFromKitRequest


FilteredProductAssociation is the view that stores the list of Products that belong to a kit. There is no entity available called ProductAssociation that you can make an object of directly. But using link entity in query expression and linking it to ProductAssociation would work.

Monday, February 9, 2009

Microsoft Office Accounting Integration Link with Microsoft Dynamics CRM released which supports Dynamics CRM version 4.0 On-Premise/CRM Live

Microsoft Office Accounting is one of the most popular accounting packages from Microsoft for small and medium industry. Dynamics CRM is one of the most popular CRM systems being deployed by Microsoft consultants. Linking the two applications has been a crying need for resellers, prospects and end users of Dynamics CRM system.

To bridge the gap for the users, we have come up with a link which has the following features:

Customer Synchronization: Accounts of Dynamics CRM and Customers of Office Accounting are completely synchronized. You can save an Account in Dynamics CRM and promote it to Office Accounting. Vice versa, you can synchronize customers from Office Accounting applications to view and edit it in Dynamics CRM. Any edit and update on the Dynamics CRM side reflects in Office Accounting in the real time.

Invoices and Orders Viewing in Dynamics CRM:
Complete view of a particular customers Invoice and Orders history in Dynamics CRM within its tabs.

Promote Orders from Dynamics CRM:
This feature is extremely useful for Sales people to make Orders against opportunities in CRM and then promote it to Office Accounting for further processing.

Quick Customer Account Information: Various financial important data like Credit Limit, Aging, and Terms etc from the Office Accounting is available against the Dynamics CRM customer for viewing of Sales People.

Versions supported:
Microsoft Office Accounting: US Edition – 2008/2009/2010/2011, UK Edition - 2008/2009/2010

Microsoft Dynamics CRM: 4.0 On-premise and CRM Live.

Download White Paper