Wednesday, December 1, 2010

Map Custom Attributes from Opportunity Product to Quote Product to Order Product and so on in Microsoft Dynamics CRM Online 2011 and 4.0

The process of mapping custom attributes in Microsoft Dynamics CRM Online from opportunity product to quote product to order product to invoice product is very similiar in CRM Online as it is in on-premise CRM.  There is just one problem that needs to be overcome, and that is getting the GUID for the entitymap entities from the CRM backend to plug into the URL that is required to add custom attributes to the mappings.  

If you want to know how this works in on-premise using SQL management studio please review my older  blogpost at: http://mileyja.blogspot.com/2008_09_01_archive.html.

There are some issues that arise out of using CRM Online as you cannot access the SQL Server your instance resides on, this means you cannot easily get the GUIDs you need from the backend unless you use web services to retrieve them.  I know the metadata browser in 4.0 does not show the entitymap entity in the menu as entity you can drill down on, but believe me you can access this entity using a retrieve or retrievemultiple call using SOAP in jscript through the 2007 web services (which were also conveniently left in place for backward compatibility in CRM 2011).  The other issue is that there is a minor change to the URL you need to use to access the custom mapping as CRM Online follows the IFD url structure for where the orgname is located.

1. First, you will need this jscript that you can attach to any entity form event in CRM to get the guid when that event is executed in order to retrieve the unique entitymapid for your organization to map from salesorderdetail (Order Product) to invoicedetail (Invoice Product).  Since this only needs to be done once, you can just attach it to an event and use the preview form function to retrieve the GUIDs and then remove the jscript without ever publishing it.

First in 4.0 Online or On-Premise:

//create SOAP envelope
var xmlSoapHeader= "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"
http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
var xmlAuthHeader = GenerateAuthenticationHeader();
var xmlSoapBody = "<soap:Body>" +
"<RetrieveMultiple xmlns=\"
http://schemas.microsoft.com/crm/2007/WebServices\"> " +
"    <query xmlns:q1=\"
http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryByAttribute\" xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"      <q1:EntityName>entitymap</q1:EntityName>" +
"      <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
"        <q1:Attributes>" +
"          <q1:Attribute>entitymapid</q1:Attribute>" +
"          <q1:Attribute>sourceentityname</q1:Attribute>" +
"          <q1:Attribute>targetentityname</q1:Attribute>" +
"        </q1:Attributes>" +
"      </q1:ColumnSet>" +
" <q1:Attributes>" +
" <q1:Attribute>sourceentityname</q1:Attribute>" +
" </q1:Attributes>" +
" <q1:Values>"+
" <q1:Value xsi:type=\"xsd:string\">salesorderdetail</q1:Value>" +
" </q1:Values>" +
"    </query>" +
" </RetrieveMultiple>" +
"  </soap:Body>" +
"</soap:Envelope>" +
"";


var xmlt = xmlSoapHeader + xmlAuthHeader + xmlSoapBody;
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","
http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xmlt.length);
xmlHttpRequest.send(xmlt);
var resultXml = xmlHttpRequest.responseXML.xml;

alert(resultXml);

Now in CRM 2011 Online or On-Premise you can use the same script, but it must be encapsulated in a jscript library as a function that you call from the event:

function testfunc()
{
//create SOAP envelope
var xmlSoapHeader= "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"
http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
var xmlAuthHeader = GenerateAuthenticationHeader();
var xmlSoapBody = "<soap:Body>" +
"<RetrieveMultiple xmlns=\"
http://schemas.microsoft.com/crm/2007/WebServices\"> " +
"    <query xmlns:q1=\"
http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryByAttribute\" xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"      <q1:EntityName>entitymap</q1:EntityName>" +
"      <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
"        <q1:Attributes>" +
"          <q1:Attribute>entitymapid</q1:Attribute>" +
"          <q1:Attribute>sourceentityname</q1:Attribute>" +
"          <q1:Attribute>targetentityname</q1:Attribute>" +
"        </q1:Attributes>" +
"      </q1:ColumnSet>" +
" <q1:Attributes>" +
" <q1:Attribute>sourceentityname</q1:Attribute>" +
" </q1:Attributes>" +
" <q1:Values>"+
" <q1:Value xsi:type=\"xsd:string\">salesorderdetail</q1:Value>" +
" </q1:Values>" +
"    </query>" +
" </RetrieveMultiple>" +
"  </soap:Body>" +
"</soap:Envelope>" +
"";


var xmlt = xmlSoapHeader + xmlAuthHeader + xmlSoapBody;
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","
http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xmlt.length);
xmlHttpRequest.send(xmlt);
var resultXml = xmlHttpRequest.responseXML.xml;

alert(resultXml);
}


2. Now run the form event you attached the jscript to.

The alert message is a little bit difficult to look at when the script executes, but if you use fiddler to capture your sessions, it will show you the needed entitymapid GUID quite nicely:



3.  Now you can piece together the URL for the mapping interface for the custom attribute mapping.  The syntax to use is:

 https://myorgsubdomain.crm.dynamics.com/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=entitymapidGUID

Here is a syntax example using the guid above:

https://myspecialcrminstance.crm.dynamics.com/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=EB562CC6-991B-DF11-87A9-02BF0A0679DE

NOTE:  Since the GUIDs are unique to each organization of CRM, the GUID in the URL won't actually work except in my own personal organization.

4. Navigate to the URL using your browser and below is the resulting screen.  You should see a similiar mapping dialog when you click "New" on the screen.  I chose to show you the end result from 2011 in the following screenshot for the mapping screen, it looks only a bit different in 4.0 Online and functions the same way.



Thats all there is to it, just add you mappings as needed.  If you need to get the other GUIDs for the other detail (product) entities in the sales process chain you just change the entity types in the script and re-run it.


This post is provided as-is and implies no warranty, Jamie Miley does not assume any responsibility for problems arising from the use of this information.

Friday, October 1, 2010

Baby Addie's First Blog Post

My beautiful daughter is 7 months old today, it is about time she started blogging.  Below is her first expression in cyberspace.  I just let her have the keyboard for awhile.  Notice that besides random keys, she also managed to insert the day and time 4 times in the file.  I don't even know the keystroke for that one!  She also seems to think her signature is "MK,,"

Begin Adelyn:

hx
k v bvvvvvvv fvcv/;/...,.......................................
..,m;;pi0k.

c6575,ttttttft6666gyt.............................. fd essssssssssss KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
7:20 PM 10/1/20107:20 PM 10/1/20107:20 PM 10/1/20107:20 PM 10/1/20106Y^
^yyyszzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,zzzzzzzzzzzzzzzzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,eessssssazyyyyyyytzzzzzzzzzzzzzzzzzzzzzk,z zz
vvvvvvvvvvvvvvv ???????????????????????????C
.nb r9jmmmmmmmmmmut5ttttttttttttttttttttttttttttttttttttttttttttttttttttyf/kscvvvvvvvvvvvvvvvvvvvvvvvvvvvv zxs4rftttttttttttt,de ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
iuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu7u8aZnnnnnnnnnnnnnnmmmmnl NYYYYYYYYYYYYYYHHHHHHHHHHHHHHH ,, ,,='[=
MK,,

Wednesday, December 2, 2009

My First Published Patent Application

I guess I can call the mom and tell her to add another entry to the baby book. Baby's first published patent application. Its for a
Scanning Apparatus and System for Tracking Computer Hardware. I wrote a lot of the content myself and did the diagrams.

This whole thing came about when my wife's laptop was stolen from her car one night and I developed a way to find it. I tried out my new idea and found the laptop in less than a half hour and put the guy in jail.

For the full PDF patent application that was published by the USPTO, please click the link below:

http://www.freepatentsonline.com/20090210935.pdf

Monday, June 8, 2009

David Groos and His Linux Classroom Project (and me) Make It Into The Minnesota Business Journal

getSTEM, David Groos, and the Growing Communities of Scientists Project make it into the Minnesota Business Journal.  If you haven't heard of this project it is a great effort by teacher David Groos to bring technology into his classroom affordably by using Linux and LTSP  Read the article here.  I have to say, I was more than a little elated to see that this type of thing is getting press.  Not to mention they mention my name in the article :)

Check it out!!:  http://www.minnesotabusiness.com/0p349a2857/do-you-get-stem/

Sunday, March 8, 2009

getSTEM + Linux in the Classroom = Awesome!!!

[caption id="attachment_67" align="alignnone" width="300" caption="Ahh,  the sweet smell of success.... and toner "]Me fixing the printer[/caption]

I recently had the pleasure of helping David Groos with a Linux networking problem specifically with setting up LTSP (Linux Terminal Server Project) with multiple NIC cards and subnets. I heard about this through my wife who works with Inetium in Bloomington, MN.  They are partnered with a group called getSTEM.  getSTEM is dedicated to helping educators find help, guest speakers, or just about anything from ordinary individuals and companies.  It's a great resource and is specifically dedicated to promoting the areas they call STEM (Science, Technology, Engineering, and Math).

David is currently trying to further his district by bringing Ubuntu Linux into his science classroom. I really admire this initiative, and I feel that open-source software could dramatically change how technology-based education works in school districts. Because the software is free and works on machines that are a bit older, this could easily save districts millions of dollars in computer hardware and software.

I encourage people to look at David's blog and see what he is doing to change the way technology-based education. If you are interested in hearing about my contribution, the specific link is (http://groosd.blogspot.com/2009/03/fixed-network-and-thus-printer.html)

Sunday, November 23, 2008

TortoiseSVN checkout problem, ok button is grayed out w/ resolution.

I started using TortoiseSVN the other day and found that when I would attempt to checkout a repository I couldn't do it because the "ok" button was grayed out and I could not find good info on what might cause such a problem, but I finally did figure it out.

RESOLUTION:

I found that adding a slash "\" to the end of the checkout directory field after I chose the directory fixed the problem.

EXAMPLE: If you have a folder called c:\test and you browse to it because you want that to be your checkout directory the field is then filled with the value "c:\test". You will notice that the "ok" box remains grayed out. The program actually requires an extra slash at the end of the directory name that isn't put there by the browse control but can easily be added manually after the fact. So if you change the value to "c:\test\" the ok box will no longer be grayed out and you can continue your checkout operation.

NOTE:  This problem was found on TortoiseSVN version 1.5.5, I have no experience with similar problems with other versions.

Thursday, October 16, 2008

Windows Live Login Problems, the Wheel Just Spins... [Resolved]

Ever since I got Qwest DSL I have been unable to log into http://login.live.com, Windows Live Messenger, or anything using Windows Live authentication. I did not have this problem with my Mediacom cable-based internet service. I tried everything under the sun and found that if I changed my router's MTU setting from the default value of 1500 to a manual setting of 1400, the problem was resolved.