Relationship Mapping (CRM 4.0)

You might have noticed, how certain fields are automatically populated sometimes, whenever a new form is opened from the CRM UI.
Try creating a new Case from the Contract form. The customer and contract fields are automatically populated on the new Case form. Similar to various other entities too.
CRM provides an excellent functionality but often quite ignored by automatically mapping attributes from one entity to another within a 1: many relationships.

Open the CRM window and goto  Settings  -> Customization  ->  Contract  -> 1:N Relationships  -> contract_cases  -> Mappings

map

There are 2 fields already mapped between the contract and case. It is this mapping which defines the fields to be populated when a new Case form is opened from its Parent Form (Contract)
You can use the ‘New’ button to define additional mappings. Mapping is not only related to system attributes, you can define them for custom attributes as well.

Note: Mappings can be defined only for entities within a 1: many relationships

Mapping can be defined for most Entities: Account to Contact, Opportunity to Quote, Quote to Order, Order to Invoice, Contract to Case etc.
So if you try converting a Quote to an Order, you will notice that all fields of the Quote and QuoteDetail are automatically pushed into the SalesOrder and SalesOrderDetail

However consider a scenario, where you need custom fields on QuoteDetail to be transferred to the custom Fields available on the OrderDetail. If you have a look at the QuoteDetail relationships, you will find that no relationship exists between the QuoteDetail and OrderDetail. So how do you go about mapping the custom fields?

Well, CRM definitely has a relationship between the QuoteDetail and OrderDetail Entities, however for some reason unknown, its hidden from the UI.

Here’s an UNSUPPORTED technique to unearth these relationships. So for the above example, we need to transfer QuoteDetail custom attribute values to the  OrderDetail Entity.

Within SQL, run the below query:
Select * from entitymapbase where targetentityname = ‘orderdetail’
This query will return 3 items, pick the row with the ‘SourceEntityName’ column value of  “quotedetail”.
Copy the GUID value available in the EntityMapId column for this row.

Paste the GUID at the end of the below URL
http://servername:port/orgname/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=

That opens up the secret mapping page ……
You can use this to map your custom fields as well.

CRM Picklist and the StringMap Table (CRM 4.0)

If you have a look at the CRM base tables (eg: AccountBase) in MSCRM, you would notice that all columns of Picklist datatype seem to store Integer values. So from where exactly does CRM get the actual text value to be displayed on the UI?

Well, this comes from a not so well known table called ‘StringMap’. MSCRM stores all related option values for any picklist in this table.

Here’s the Structure of the StringMap Table:
Column Name
Description
StringMapId
Primary ID of the record
ObjectTypeCode
Object Type Code of the entity
AttributeName
Schema Name of the picklist attribute
AttributeValue
Integer value of the picklist option. This value is actually stored in the base tables.
LangId
Language Code
OrganizationId
Organization ID
Value
text value displayed within the picklist on the CRM UI
DisplayOrder
Order of the values in the picklist on the CRM UI
VersionNumber
Last updated Timestamp (used during synchronization process)

Modifying the StringMap table to add new values is not recommended and can cause undesired results. In fact, CRM does not support modifying any of the CRM tables directly. All updates are to be made via the CRM UI or Web Services.

CRM seems to store picklist values in 2 tables:
1. StringMap
2. Metadataschema.AttributePicklistValue(This seems to be used as a temporary table)

Whenever an option value is added/edited/deleted for any picklist and saved from the UI, CRM updates theMETADATASCHEMA.AttributePicklistValue table. Upon publish of the Form the values are pushed into the StringMap table based on the values in the above table.
Hence directly updating the StringMap table via SQL with new values won’t suffice, since CRM will replace the values in DB with the new values when the Entity is published via the UI.
There are 2 possible ways to edit picklist values:
1. The Metadata Service (The only SUPPORTED way to add/edit/delete picklist values)
2. Modifying the Entity XML. (This requires editing the XML file for an entity)(UNSUPPORTED)Newly created values for any system picklist will have a value of 200000 or greater. This is to maintain backward compatibility during upgrades from CRM 3.0. This ensures that up to 199999 values for any picklist from CRM 3.0 will be successfully transferred during an upgrade to CRM 4.0
Note: Newly created values for any custom picklist would, however, start from 1.

Below is an example of both the options:

Option 1:

//Example for creating an option via the Metadata Service:
CrmLabel crmLabel = new CrmLabel();
LocLabel englishLabel = new LocLabel();
CrmNumber langCode = new CrmNumber();
// Set lang code as English
langCode.Value = 1033;
englishLabel.LanguageCode = langCode;
englishLabel.Label = “New Value”;
crmLabel.LocLabels = new LocLabel[] { englishLabel };
//Create the Insert Request
InsertOptionValueRequest insertRequest = new InsertOptionValueRequest();
//Set the Entity Name
insertRequest.EntityLogicalName = EntityName.contact.ToString();
//Set the Attribute Name
insertRequest.AttributeLogicalName = “customertypecode”;
insertRequest.Label = crmLabel;
insertRequest.Value = new CrmNumber();
insertRequest.Value.Value = 200000;
//Execute the Insert Request
InsertOptionValueResponse insertResponse = (InsertOptionValueResponse)metadataService.Execute(insertRequest);
//Example for deleting an option via the Metadata Service:
//Create the Delete Request
DeleteOptionValueRequest deleteRequest = new DeleteOptionValueRequest();
//Set the Entity Name
deleteRequest.EntityLogicalName = EntityName.contact.ToString();
//Set the Attribute Name
deleteRequest.AttributeLogicalName = “customertypecode”;
//Declare the Attribute Value
deleteRequest.Value = 200000;
//Execute the Delete Request
DeleteOptionValueResponse deleteResponse = (DeleteOptionValueResponse)metadataService.Execute(deleteRequest);

Option 2
:
Export the required entity. (MSCRM-Settings-Customization-Export Entities) OR use the ExportXmlRequest and ExportXmlResponse if you want to perform the export via web services.
Open the file within an XML Editor.
Search for the attribute schemaname you want to update.
You should find something similar to the text given below
                <options>
<option value=”1″>
<labels>
<label description=”Buyer” languagecode=”1033″ />
</labels>
</option>
<option value=”2″>
                  <labels>
<label description=”Seller” languagecode=’1033″ />
</labels>
</option>
</options>
An additional option node would need to be created for every new option you want to add.
Eg :
<option value=”200000″>
<labels>
<label description=”Re-Seller” languagecode=”1033″ />
</labels>
</option>You can use the ImportXmlRequest/ ImportXmlResponse and PublishXmlRequest/ PublishXmlResponse classes to publish the xml back into CRM.

No Item Exists Error Because of Querystring Parameter Name

When working with Data views and filters in Sharepoint Designer, the Sharepoint page may sometimes throw an odd error like

No item exists at http://sitename/pagename.aspx?Id=2.It may have been deleted or renamed by another user.

The typical cause for this issue is that a dataview webpart within the page uses a filter condition that maps ID property of a list to a querystring parameter whose name is ID.

The issue can be easily solved by renaming the querystring parameter to a different name other than ID. After renaming the parameter the Sharepoint page will work as expected.

Twitter Trends SharePoint Webpart

We have developed a webpart that will allow to display the top 10 trending topics in Twitter within a Sharepoint web page. The webpart uses a combination of JSON and JQuery.  The webpart along with installation instructions can be downloaded from here

Silverlight Loader SharePoint webpart

In order to add a Silverlight application to Sharepoint web page, we need to add a content editor web part and insert HTML object tag with appropriate properties. In order to make this process easier, we have developed a Silverlight Loader webpart.

This webpart will take in the Silverlight 2.0 application file (XAP) file path and loads the Silverlight application within the Sharepoint page. The webpart along with installation instructions can be downloaded from here

New SharePoint Features are Not Available in Visual Studio 2010 Beta1

After viewing the Channel 9 video on Sharepoint development with Visual Studio 2010 we were eagerly waiting for the for the Visual Studio 2010 beta release to try out all those Sharepoint goodies. But when we downloaded and used the Visual Studio2010 Beta 1 released last week, we were disappointed to see that only two Sharepoint templates were available. The ones for sequential and state machine workflows. The templates for other Sharepoint project types such as webparts, lists etc were missing.

 

Later we understood from the MSDN forum that the full Sharepoint features is stated only for Beta 2 release of Visual Studio 2010. So we need to wait until then.

Increase Print Font Size of SharePoint Pages

Through the default font sizes in Sharepoint web pages might look fine on Internet Explorer browser screen, they will be very small when a print is taken of the page. This blog explains how to fix the issue by using the CSS media rule.

The CSS 2 media rule specifies how a web page will be displayed in different types of media. Using this rule we can specify different style settings for different media such as a screen, print, mobile etc. For more information on CSS media rule visit http://www.w3.org/TR/CSS2/media.html

With the default Sharepoint styles the font size will look alright when viewing on screen, but when the page is printed the font size will be very small and the content nonreadable.  The problem can be solved by adding media rule style settings to the Sharepoint master page (usually Default.Master). To increase the print font size we need to set the print media rule. This can be done in two ways

Internal Style Sheet

Add the following style tag to the Sharepoint master page

<style type=”text/css“> 
@media print 

   BODY {font-size: 12pt; line-height: 24px; !important} 
       TD { 
    font-size:12pt; line-height: 24px;  !important} 

</Style>

External Style Sheet

Add the style tag in an external CSS file and refer to it in the Sharepoint master page using the link element.

 <link rel=”stylesheet” type=”text/css” href=”print.css” media=”print” />

Adding CSS media rule using any of the above-mentioned methods will increase the print font size of Sharepoint pages without affecting the visual appearance.

Cheers,

V.Kumar

 

Posting to SharePoint Blogs with Live Writer

Windows Live Writer is a desktop application that makes it easier to create gripping blog posts. Live Writer has a lot of features that give better blog experiences such as WYSWIG authoring, Photo Publishing, Map publishing, Video embedding etc. Windows Live Writer is free and can be downloaded.

Live Writer supports posting to popular blogging sites such as Live Spaces, Blogger, WordPress etc. Live Writer also supports posting to SharePoint blog site. Rest of this blog explains the process of setting up Live Writer to post to a SharePoint blog site.

1. The first step is to add a blog account to SharePoint blog from Live Writer. Click Blogs – Add blog account from the writer menu bar.

2. This would open a popup prompting to select the blog service to be used.

Livewriterselectblogtype

3. Select SharePoint blog and click Next button.

4. The next screen would prompt for the SharePoint blog URL. Enter the URL of your blog(for ex. http://MySite/Myblogsite and click Next)

5. Live Writer would configure blog settings and take you to blog post creation page.

6. Enter post title and content.

7. You can also add photos, links, videos etc to your blog post

8. Once you are satisfied with the content and styling of photos click publish button on the tool bar to post the blog to the SharePoint blog website.

9. That’s it your blog will be posted to the SharePoint blog site.

Restrict Removable Storage Devices Using Group Policy in Windows Server 2008

In Windows Server 2008 domain, there are a set of built-in policies on removable storage access and installation. It makes restricting USB mass storage device easier.

Open the Group Policy Manager in your windows server 2008 and Do the following Steps,

1. Computer Configuration–>Policies–>Administrative Templates–>System–>Removable Storage Access
    User Configuration–>Policies–>Administrative Templates–>System–>Removable Storage Access
It specifies read and write permission on all kinds of the removable storage device.
2. Computer Configuration–>Policies–>Administrative Templates–>System–>Device Installation–>Device Installation Restrictions
With device installation restrictions, the installation of the removable storage device will be totally under control.

Speeding Up SharePoint Pages Loading by Removing core.css

Shantha Kumar – MCTS
[email protected]

Sharepoint site pages by default will reference to core.css file. The core.css has reference to a lot of image files and http request will be placed to download the files even if it is not used in the page. This is not a desirable situation for public facing Sharepoint sites.  In order to prevent core.css from being referenced the following CSS link reference has to be removed from the master page.

Once the CSS link is removed core.css will not be referred and therefore associated images will not be downloaded.  Below is the snapshot from websiteoptimization.com which shows the number of requests with core.css and without core.css

With core.css

Total HTTP Requests:

75

Without core.css

Total HTTP Requests:

41