tag:blogger.com,1999:blog-11305131572704906372024-03-14T00:29:10.597-07:00MSCRM Dynamics 2011 TipsAli Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-1130513157270490637.post-40949088372153621332012-04-26T07:28:00.000-07:002012-04-26T07:28:18.332-07:00CRM UI Tip: Chnaging prefix of custom entities1. Go to the default publisher record. Its located in the Customizations section of CRM 2011.<br />
2. Locate the prefix box at the bottom left of the form.<br />
3. Update and save.Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-82841592073398165902012-04-26T07:11:00.002-07:002012-04-26T07:12:39.464-07:00CRM 2011: Disable Duplicate Detection Save button on PopupSo in my efforts to reduce usage of plug-ins in CRM 2011, I decided to re-evaluate the duplicate detection I had designed.<br />
<br />
<u>Quick Overview:</u><br />
CRM 2011 allows you to create duplicate detection rules that will attempt to find duplicates on criteria you select. However, the user has the ability to save the record regardless. My first inclination was to create a couple of reference entities and utilize the Create and Update message of the plug-ins. After talking with some other CRM guys, I've learned that handling writing of any entity is just too costly.<br />
This technique I will describe below will change the behavior of the duplicate detection view duplicates page. If you don't want to do this proceed no further.<br />
<br />
<u>Instructions:</u><br />
1. Navigate to your CRM instance on your app server.<br />
2. Navigate to \CRMWeb\Tools\DuplicateDetection\ViewDuplicates\<br />
3. Edit this file in Visual Studio or Notepad.<br />
4. Add this line to the ShowPage() javascript member or any member that is called by onLoad():<br />
<b>document.getElementById("btn_id_Ok").disabled="true";</b><br />
5. Save your change.<br />
<br />
This simply disables the button as you can tell. The fun part would be to allow not allow by the current user's role. I suggest using WhoAmI() or any AJAX call to accomplish what you want.<br />
<br />
Happy Coding!<br />
<br />Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com2tag:blogger.com,1999:blog-1130513157270490637.post-13751324906345464352012-04-19T10:12:00.000-07:002012-04-19T10:12:10.234-07:00CRM2011: Export entities from one organization and import to another while changing the ownership of the entity.In this post I will demonstrate, with code examples, how to export your structure from one org to another using the SDK.<br />
Before I really got knee deep in it, my first inclination was to modify the customizations.xml file and import into the new org. The idea of modding the xml is a great way to However considering the idea of creating relationships and lookup fields, this practice always fails.<br />
The solution lies within the SDK of CRM 2011.<br />
<br />
The basic concept is this:<br />
1. Retrieve the entity structure from one organization.<br />
1b. Modify structure as needed. In my case I need to change the ownership to user/team owned but you can also add fields, views, etc.<br />
2. Loop through the custom entities and add to new organization.<br />
<br />
In reality, at a low level viewing, it works like this:<br />
1. Retrieve the entity structure from one organization.<br />
2. Loop through the custom entities and add to new organization.<br />
2a. Find entities where prefix matches yours to filter out system entities.<br />
2b. Modify structure as needed. In my case I need to change the ownership to user/team owned but you can also add fields, views, etc.
<br />
3. Create new entity, minus any attributes.<br />
4. Create attributes that aren't of type Lookup.<br />
5. Do Steps 2 and 2a.<br />
6. Create one to many relationships for each entity. This will create the many to one to the corresponding entity and also the lookup attribute you filtered out earlier.<br />
7. Create many to many relationships.<br />
8. Complete.<br />
<br />
<u>SDK objects used:</u><br />
enums for componenttype and systemformtype. located at helpercode\optionsets.cs<br />
Microsoft.Xrm.Sdk.Messages<br />
Microsoft.Xrm.Sdk.Metadata<br />
AttributeTypeCode<br />
RetrieveAllEntitiesRequest<br />
RetrieveAllEntitiesResponse<br />
EntityMetadata<br />
AttributeMetadata<br />
CreateEntityRequest<br />
CreateAttributeRequest<br />
ManyToManyRelationshipMetadata<br />
CreateManyToManyRequest<br />
CreateOneToManyRequest<br />
LookupAttributeMetadata<br />
<br />
<u>Members to create:</u><br />
<br />
<ul>
<li>member using RetrieveAllEntitiesRequest and RetrieveAllEntitiesResponse to get entity structure.</li>
<li>member using CreateEntityRequest to create entity.</li>
<li>member using CreateAttributeRequest to create entity. This member will need to filter using AttributeTypeCode.Lookup.</li>
<li>member using CreateOneToManyRequest and LookupAttributeMetadata to explicit bind a new relationship. The lookup needs to be created in the request.</li>
</ul>
<div>
<u>Considerations:</u></div>
<div>
<ul>
<li>When using RetrieveAllEntitiesRequest set the EntityFilters property to All. This will take longer but will grab all attributes and relationships if you want to do this in one routine.</li>
<li>When looping through, do a conditional to only run process on entities that are custom.</li>
<li>In the CreateEntityRequest Notes and Activities won't acknowledge you structure setting so set these booleans.</li>
<li>In the CreateEntityRequest Primary Attribute has to be created. Set the RequiredLevel to None.</li>
<li>When using CreateAttributeRequest, loop through the EntityMetadata where IsCustonAttribute is true and attributeof is null. AttributeOf seems to correlate to a lookup.</li>
<li>When using the CreateOneToManyRequest, set the ReferenceEntity and the ReferencingEntity.</li>
<li>When using the CreateOneToManyRequest lookup property, get the displayname by using the localizedlabels[0].Label property.</li>
</ul>
<div>
Good Luck and comment with any questions.</div>
</div>Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-48528856862736844402012-04-11T18:09:00.001-07:002012-04-11T18:09:45.049-07:00CRM 2011: Setting up relationship to allow delete of parent but not childrenI recently have been working on dynamically changing an entity that was originally setup as organization owned to be team owned.<br />
After pulling my hair out trying various methods that would allow me to keep the data intact, I decided to export the data and empty out the entity so I can update it. This method allows me not to drop the entity and use the method from my earlier post.<br />
<br />
However, the relationships are set up as referential and that won't work for what I want since there are child records related. The way I got around this was to setup those relationships as Configure Cascade. I then selected the Remove Link action in the Delete picklist.<br />
<br />Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-70613996643035675512012-04-09T11:24:00.002-07:002012-04-11T12:14:27.893-07:00CRM 2011: Changing an entity from organization owned to team or user owned without droppingSo after my testing with role based security, it became obvious that the entities that are newly created should be given team or user based ownership to ensure the security would be used correctly.<br />
However what if you already have entities created and are unwilling to drop and recreate the entity?<br />
<br />
I have to preface this by saying this is unsupported by Microsoft but will do the trick.<br />
The key is updating not only the customizations xml file but also the EntityView in the SQL database.<br />
To do this you will need the proper role such as System Administrator.<br />
<br />
Steps:<br />
1. Gather the necessary xml needed to add owner columns and a team relationship. I find this easier if you can create a sample entity that is user or team owned and copy the specific xml. Always keep a backup of your initial solution to ensure you can roll back.<br />
<br />
2. Locate the EntityView inside your database. Navigate to the specific entity in question. Notice the OwnershipTypeMask column. This will be set to 8 and will be updated to 1.<br />
<br />
3. Update the EntityView record to OwnershipTypeMask to 1.<br />
<br />
4. Once this is done, you can now push your updates to CRM using the solution. The next steps will help you attempt to locate the nodes you need to update.<br />
<br />
5. Add the atrributes you gathered from the test entity. These include<br />
OwnerId<br />
OwnerIdName<br />
OwnerIdType<br />
OwnerIdYomiName<br />
OwningBusinessUnit<br />
<br />
6. Scroll to the <OwnershipTypeMask> node. If you are using a solution exported from before your sql change, you will have to change the value to say UserOwned.<br />
<br />
7. Add to the EntityRelationship section of the file. Again, if you have the test entity do a search for team_ and it should find it. Duplicate this and insert accordingly.<br />
<br />
I would only attempt this if you are familiar with modifying the customizations file extensively. One wrong move and you will have to try various routes to revert back.<br />
<br />
It can be done but the road is slippery when wet! :)Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com13tag:blogger.com,1999:blog-1130513157270490637.post-2931727524243615822012-04-09T05:08:00.000-07:002012-04-09T05:08:00.659-07:00CRM 2011: Utilizing Role Based Security to hide and show recordsOne of the interesting features of CRM 2011 is the expansion of the team concept in role based security.<br />
In the past, ownership of a record was on a user or organization basis. However now, a team can now own a record which can affect everything from adding roles to teams instead of users to adding multiple teams to a user.<br />
<br />
After testing out various theories using role based security, I have found that for a standard end user, implementing and maintaining roles for each is cumbersome. By removing roles from the user and adding them to the team, maintainability is often easier.<br />
<br />
A useful way of implementing teams is allowing access to individual records in an entity. Each team can have certain access, such as read or write, but also you can hide individual records from users who shouldn't have access.<br />
<br />
Example:<br />
<br />
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">1.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Create 2 entities.</span></div>
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">2.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Create 2 Business units.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">a.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">These
business units represent a client such as Apple and Microsoft.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">b.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">When
creating a business unit, you must declare a parent. The parent in this case
will be the master data. An example would be something like software.</span></div>
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">3.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Create 2 Teams.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">a.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">These
teams are assigned to their respective Business Unit. This step is optional since creating a Business Unit above also creates a Team with the same name.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">4.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Update a standard role in CRM to only show business unit when reading.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">a.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">This
is represented by the yellow half circle.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">5.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Remove role from user.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">a.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">If
a role is set to the user, it will override roles implemented in the team.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">6.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Add update role to the each team.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">a.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">This
step and the before mentioned are gotchas.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: .75in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span lang="EN-US">7.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Add three records to the team owned parent entity.<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">a.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Three
records were created, one owned by the master data team. One owned by Apple and
one by Microsoft.</span></div>
<div class="MsoListParagraph" style="margin-left: 1.25in; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span lang="EN-US">b.<span style="font-size: 7pt;">
</span></span><span lang="EN-US">Ideally
in this step we should only see 2 records. Master and whatever team(s) the user
is a part of.</span></div>
<br />
So say your three records consist of Photoshop, Final Cut Studio and Microsoft Office.<br />
You would want Photoshop accessible by both since it runs on both Apple and MS software.<br />
However you wouldn't want to see Final Cut Studio as a MS Employee not MS Office as an Apple Employee.<br />
By following the above example, you can add users to teams associated to each record and they will only see the two specific records.<br />
The reason they both see Photoshop is because its owned by the master BU which both BUs are a child of.<br />
<br />
If implemented correctly, this feature can be utilized and all facets of CRM; including xRM, dashboards, reporting, etc.<br />
<br />
Also if you have a developer or system admin user and want to see all records, simply add the system administrator role to the user.<br />
<br />
<b>If a role is set to a user, it will override any team roles.</b><br />
<b><br /></b><br />
Happy Coding!Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-18624777787810719262012-03-28T08:13:00.000-07:002012-03-28T08:14:36.227-07:00CRM 2011 Tool Tip: Customizations using System Settings. Application and Form Mode.<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-U74U8SLcz-o/T3MGtuUz3fI/AAAAAAAAAO8/JRRGRV2eHzc/s1600/System+Settings+-+Cust.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="color: white;"><img border="0" height="230" src="http://1.bp.blogspot.com/-U74U8SLcz-o/T3MGtuUz3fI/AAAAAAAAAO8/JRRGRV2eHzc/s320/System+Settings+-+Cust.png" width="320" /></span></a></div>
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">With the release of Rollup 7 to CRM 2011, the Read-Optimized form mode has now been made available for the individual user to choose. However if you want to make the change globally, or not allow an individual user to choose what type of mode you have to adjust the System Settings.</span><br />
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Navigate to the System Settings pane you see above. Choose the Customization tab.</span><br />
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="color: white;"><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Application Mode - </span><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Application mode setting. In System Settings you can choose whether Microsoft Dynamics CRM will launch in application mode. Application mode hides the address, tool, and menu bars on the browser.</span></span><br />
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"></span><br />
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Form Mode - Within form mode you can choose to default the form to editable or read only. You can also disable users from selecting the other option. However since Read Optimized is new, let's go deeper into that.</span><br />
<span style="color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="color: white;"><span style="background-color: black; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 15px; line-height: 22px; text-align: left;">. However, if your IFrame calls in to the client API to get some form data, you might get errors on the form because read-optimized forms don’t have client API support.</span>
</span><br />
<div style="text-align: left;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="color: white; font-size: 15px; line-height: 22px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="color: white; font-size: 15px; line-height: 22px;">So far my testing has revealed the following:</span></span></div>
<div style="text-align: left;">
</div>
<ul>
<li><span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="color: white; font-size: 15px; line-height: 22px;">If your instance of CRM has global javascript files as Web Resources or in fact if you rely on Web Resources in any facet, the form will auto select the Editable form.</span></span></li>
<li><span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="color: white; font-size: 15px; line-height: 22px;">When removing Web Resources, the form goes into read-optimized view.</span></span></li>
<li><span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="color: white; font-size: 15px; line-height: 22px;">When pointing to an aspx page, the form is currently failing. The aspx page I am trying to load will invoke a silverlight xap file.</span></span></li>
</ul>
<div>
<span style="font-family: Calibri, Arial, Helvetica, sans-serif;"><span style="color: white; font-size: 15px; line-height: 22px;">This topic is still in progress and I will update accordingly.</span></span></div>
<br />
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"></span><br />
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"></span>Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-20699913717570644252012-03-20T18:21:00.000-07:002012-03-20T18:21:52.038-07:00CRM 2011 and OData: Retrieve Example Using Async and Sync Methods<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">I've found in my transition from CRM 4 to CRM 2011 the ability to use REST and SOAP to be the two biggest improvements to developers. The benefit of both is essentially making the CRM 2011 UI fluid similiar to AJAX. In fact, this example used an AJAX call.</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">In this example </span></span><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">I have
successfully used oData to query the db and return a value which can be used to
validate ribbon buttons, data, etc.<o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">At the
moment this is only configured to retrieve but we can easily extend to create
and update.</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;">retrieveRecord: function (id, odataSetName, successCallback, errorCallback) {<br /> //GetGlobalContext function exists in ClientGlobalContext.js.aspx so the<br /> //host HTML page must have a reference to ClientGlobalContext.js.aspx.<br /> var context = this.GetCrmContext();</span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"> //Retrieve the server url, which differs on-premise from on-line and <br /> //shouldn't be hard-coded.<br /> var serverUrl = context.Page.context.getServerUrl();<br /> //The XRM OData end-point<br /> var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";</span></div>
<span lang="EN-US" style="mso-ansi-language: EN-US;"><div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /> //id is required<br /> if (!id) {<br /> alert("record id is required.");<br /> return;<br /> }<br /> //odataSetName is required, i.e. "AccountSet"<br /> if (!odataSetName) {<br /> alert("odataSetName is required.");<br /> return;<br /> }</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
if (successCallback != null) {<br /> //Asynchronous AJAX function to Retrieve a CRM record using OData<br /> $.ajax({<br /> type: "GET",<br /> contentType: "application/json; charset=utf-8",<br /> datatype: "json",<br /> url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'" + id + "')",<br /> beforeSend: function (XMLHttpRequest) {<br /> //Specifying this header ensures that the results will be returned as JSON. <br /> XMLHttpRequest.setRequestHeader("Accept", "application/json");<br /> },<br /> success: function (data, textStatus, XmlHttpRequest) {<br /> if (successCallback) {<br /> successCallback(data.d, textStatus, XmlHttpRequest);<br /> }<br /> },<br /> error: function (XmlHttpRequest, textStatus, errorThrown) {<br /> if (errorCallback)<br /> errorCallback(XmlHttpRequest, textStatus, errorThrown);<br /> else<br /> errorHandler(XmlHttpRequest, textStatus, errorThrown);<br /> }<br /> });<br /> }<br /> else {<br /> var request = new XMLHttpRequest();<br /> request.open("GET", serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'" + id + "')", false);<br /> request.setRequestHeader("Accept", "application/json");<br /> request.setRequestHeader("Content-Type", "application/json; charset=utf-8");<br /> request.send();<br /> var $objJquery = jQuery.parseJSON(request.responseText);<br /> return $objJquery.d;<br /> }</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
}</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
GetCrmContext: function () {</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
var params = null;<br /> var myXrm = null;</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
// Get XRM object (if possible)<br /> try {<br /> if (typeof (Xrm) != 'undefined' && Xrm != null) {<br /> myXrm = Xrm;<br /> }<br /> }<br /> catch (ex) {<br /> // DO NOTHING<br /> }<br /> return myXrm;<br /> }</div>
</span><div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">The method
has 4 parameters, 2 of which are required:<o:p></o:p></span></span></div>
<br />
<div class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span lang="EN-US" style="mso-ansi-language: EN-US; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">1.</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">The
guid of the record. This is found by using the following command: <o:p></o:p></span></span></div>
<br />
<div class="MsoListParagraph" style="margin: 0in 0in 0pt 1in; mso-list: l0 level2 lfo1; text-indent: -0.25in;">
<span lang="EN-US" style="mso-ansi-language: EN-US; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">a.</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">var
_id = Xrm.Page.data.entity.getId();<o:p></o:p></span></span></div>
<br />
<div class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span lang="EN-US" style="mso-ansi-language: EN-US; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">2.</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">string
of the entity set. i.e. new_AccountSet. <b>As with all javascript, proper
capitalization is required.</b><o:p></o:p></span></span></div>
<br />
<div class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span lang="EN-US" style="mso-ansi-language: EN-US; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">3.</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">(optional)
success Callback method. If you want to run async, provide a method and be
ready to handle the return object.<o:p></o:p></span></span></div>
<br />
<div class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span lang="EN-US" style="mso-ansi-language: EN-US; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">4.</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">(optional)
failure Callback method. Also, if async, provide a method for failure.<o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">NOTE: If
you do not set callback methods, then the method will try to run the query
inline. If successful you’ll have to provide it something to set:</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;"><span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;"> var _id = Xrm.Page.data.entity.getId();</span></span></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">
var objAccount = retrieveRecord(_id,
"new_AccountSet", null, null);<o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">If you choose to provide a success method, if might look something like this:</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt 70.8pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">function retrieveEntityCompleted(data,
textStatus, XmlHttpRequest) {</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt 70.8pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;"> _recordData = data;</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt 70.8pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><span style="font-family: Calibri;">}<o:p></o:p></span></span></div>
<br />Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-73607159028052715202012-01-19T14:49:00.000-08:002012-01-19T14:49:26.847-08:00IFRAME not showing up on CRM 2011 form<br />
So today I was tasked with removing required fields off a CRM form that also has an IFRAME and some ScriptableMember logic to tie the ribbon to the silverlight within the IFRAME.<br />
<br />
To remove the section with the required field is simple enough. First you need to export an unmanaged solution and open up the customizations.xml. Locate the section node and remove as needed. Import back in and viola. Remember to keep a copy of your export file in case something goes wrong.<br />
<br />
So once I got every field off the form except for the IFRAME, I saw that the IFRAME wasn't showing up. I checked the DOM and it did exist but the visibility was set to false. This seemed odd since all the checkboxes associated with the IFRAME and section were set to true.<br />
<br />
I decided to try to add to the footer, modified by and when, but that didn't work either.<br />
<br />
I also tried adding another IFRAME to no avail.<br />
<br />
The solution lies in using the xrm elements in javascript. I'll post the javascript now but please keep reading because yet another bug came to light after this....<br />
<br />
//the 0 will correspond with whatever tab you are working with....<br />
Xrm.Page.ui.tabs.get(0).setVisible(true);<br />
<br />
<br />
So this successfully shows the IFRAME with no other controls on the form. But once I did this I found out that the ribbon no longer functioned. After pulling all my hair out I ended up adding a crm created field in the same tab in a new section underneath and set that to invisible as well as its label. Once I did that everything worked flawlessly.<br />
<br />
Happy Coding!Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-10766667909863213602011-09-14T18:15:00.000-07:002011-09-14T18:15:17.182-07:00Accessing Silverlight from JavaScriptHey everyone!<br />
Today's post deals with accessing a silverlight web resource from javascript.<br />
An example of when this is needed is if you want ineraction between a ribbon button and an embedded silverlight control.<br />
<br />
First things first this post assumes you have already added the button to the ribbon, added the js file to the web reources and have wired up the sitemap to hit the approriate function.<br />
<br />
So at this point you're in your JavaScript function and you want to see a web resource object on the form. First, you have tro find the name of the resource (customize the form). Once you have it you need to reference in it your js code. <br />
<br />
Oh yeah that reminds me, you need to add [ScriptableType] to your code behind class and [ScriptableMember] to your member. Once you do that, you're silverlight web resource is good to go.<br />
<br />
Ok so now we have a silverlight web resource control on the form and you want to find the member.<br />
JavaScript code:<br />
<br />
var resource = Xrm.Page.ui.controls.get("WebResource_sample");<br />var obj = resource.getObject();<br />
<br />
TBD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br />
Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-35598153998141330132011-06-06T10:24:00.000-07:002011-06-06T10:24:35.597-07:00PreFiltering CRM 2011 ReportsReport prefiltering in CRM 2011 narrows the scope of a report, return faster results and can lead to more revelant data. Instead of just creating a report parameter, report prefiltering uses the Advanced Find fetch queries. This allows the creation of end user defined queries while still in CRM.<br />
<br />
A sample query:<br />
<span style="font-family: Courier New;">SELECT name, accountnumber <br />
FROM FilteredAccount as CRMAF_Account</span><br />
<br />
For more information click the link below!<br />
<br />
Happy Coding!<br />
<br />
Dynamics Blog Link:<br />
http://blogs.msdn.com/b/crm/archive/2009/03/06/microsoft-dynamics-crm-pre-filtering-tips.aspxAli Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com2tag:blogger.com,1999:blog-1130513157270490637.post-36453550616874423502011-05-05T05:38:00.001-07:002011-05-05T05:38:56.100-07:00How to Update the Primary Field of an Entity in CRM 2011Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-17337991300433775982011-04-26T08:41:00.000-07:002011-04-26T12:06:04.602-07:00Importing Solution to Another Organization Changes ObjectTypeCodeAn issue came up yesterday regarding importing one organization's customizations (sitemap, isv.config, custom entities, etc.) into another. While the files imported successfully and everything appeared correct we quickly realized one crucial error we had assumed...<br />
<br />
When importing a solution to another organization changes the ObjectTypeCode of every custom entity!<br />
<br />
The ObjectTypeCode is the database equivalent of the ETC query string parameter. In simpler terms, any reference to the etc code in the URL of any custom entity will be in correct.<br />
The issue it seems is that when importing, CRM ignores the ObjectTypeCode node in the customizations.xml and instead inserts them alphabetically instead.<br />
<br />
So if you had an entity named new_account and it had an etc of say 10100 which typically means its the one hundredth custom entity created, it will now be 10000 since it is the first alphabetically.<br />
<br />
So what's the solution?<br />
<br />
Some workarounds mentioned around the web and in the msdn forums is to use the ObjectTypeName, abbreviated OTN. If you notice when crm generates the url for a custom entity it adds this as a query string parameter labeled objecttypename=new_account.<br />
<br />
So by using this method you avoid using the etc and refer to the string equivalent. I have always assumed this etc number to carry over since its in the xml but its not.<br />
<br />
<br />
Happy Coding!Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-17269388337456734162011-04-05T10:10:00.000-07:002011-04-05T10:16:04.298-07:00TechNet Online Documentation for MSCRM 2011<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">Link:</span><br />
<a href="http://technet.microsoft.com/en-us/library/bb496811.aspx"><span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">http://technet.microsoft.com/en-us/library/bb496811.aspx</span></a><br />
<br />
<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">The link above gives you access to the technet documentation.</span><br />
<span style="font-family: Arial;">The navigation to the left will allow to choose from the following:</span><br />
<br />
<ul><li><span style="font-family: Arial;">Installation</span></li>
<li><span style="font-family: Arial;">SDK</span></li>
<li><span style="font-family: Arial;">White Papers</span></li>
</ul><span style="font-family: Arial;">The Installation section includes the following:</span><br />
<ul><li><span style="font-family: Arial;">Introduction</span></li>
<li><span style="font-family: Arial;">Planning Guide</span></li>
<li><span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">Installing Guide</span></li>
<li><span style="font-family: Arial;">Operating and Maintaining Guide</span></li>
</ul><span style="font-family: Arial;">The SDK section links to this page which will give developers sample code and quickstart solutions. The Link: <a href="http://technet.microsoft.com/en-us/library/gg309408.aspx">http://technet.microsoft.com/en-us/library/gg309408.aspx</a></span><br />
<br />
<span style="font-family: Arial;">The White Papers section currently only houses the Claims Based Authentication but will be expanded soon.</span><br />
<br />
<span style="font-family: Arial;">This is a valuable go to resource for any CRM developer!</span><br />
<br />
<span style="font-family: Arial;">Happy Coding!</span><br />
<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"><span style="font-family: Times New Roman;"> </span></span><br />
<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"><span style="font-family: "Calibri","sans-serif";"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-55-55-metablogapi/8484.image_5F00_2.png"></a></span><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><span style="font-family: Times New Roman;"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas> <v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f"> <o:lock aspectratio="t" v:ext="edit"> </o:lock></v:path></v:stroke></span></v:shapetype></span>Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0tag:blogger.com,1999:blog-1130513157270490637.post-46209177299040753642010-12-09T10:11:00.000-08:002010-12-09T10:11:51.489-08:00ISVConfig/SiteMap Tip #1: Point to an ASPX page to extend functionalitySo far it's been about 2 months since I've been working with the CRM 2011 Beta and while many things have changed drastically, the SiteMap and ISVConfig still adhere to the same rules as in CRM 4.<br />
<br />
When creating a link for the Workplace I prefer to use an ASPX page as opposed to a JS page or otherwise. The reason I use it is not only can I embed JS I can also render my own webpages, silverlight controls, etc.<br />
<br />
<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">In a real world example, you are tasked with creating a link in the workplace that not only points to the Active View of the desired entity but also opens a new window that allows you to create an instance of that particular entity. I pointed my <span style="background-color: white;">SiteMap to an ASPX page that simply ran JS onLoad:</span></span><br />
<br />
<span style="background-color: yellow;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"></span></span></span><span style="background-color: white;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><begin</span></span></span><span style="color: #3e60fd; font-family: Consolas; font-size: x-small;"><span style="color: #3e60fd; font-family: Consolas; font-size: x-small;"><span style="color: #3e60fd; font-family: Consolas; font-size: x-small;">script</span></span></span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"> language</span></span></span><span style="color: teal; font-family: Consolas; font-size: x-small;"><span style="color: teal; font-family: Consolas; font-size: x-small;"><span style="color: teal; font-family: Consolas; font-size: x-small;">="javascript"</span></span></span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"> type</span></span></span><span style="color: teal; font-family: Consolas; font-size: x-small;"><span style="color: teal; font-family: Consolas; font-size: x-small;"><span style="color: teal; font-family: Consolas; font-size: x-small;">="text/javascript"</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">></span></span></span></span></span><br />
<span style="background-color: yellow;"><span style="background-color: white;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"></span></span></span><span style="color: darkgreen; font-family: Consolas; font-size: x-small;"><span style="color: darkgreen; font-family: Consolas; font-size: x-small;"><span style="color: darkgreen; font-family: Consolas; font-size: x-small;">//Open popup and set location using CRM global var</span></span></span></span></span><br />
<span style="background-color: white;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;">window.open(<span style="color: maroon;">'/'</span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"> + parent.top.ORG_UNIQUE_NAME + </span></span></span><span style="color: maroon; font-family: Consolas; font-size: x-small;"><span style="color: maroon; font-family: Consolas; font-size: x-small;"><span style="color: maroon; font-family: Consolas; font-size: x-small;">'/userdefined/edit.aspx?etc=10002'</span></span></span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;">, </span></span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">null</span></span></span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;">);</span></span></span><br />
window.location.href = </span></span></span><span style="color: maroon; font-family: Consolas; font-size: x-small;"><span style="color: maroon; font-family: Consolas; font-size: x-small;"><span style="color: maroon; font-family: Consolas; font-size: x-small;">'/'</span></span></span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"> + parent.top.ORG_UNIQUE_NAME + </span></span></span><span style="color: maroon; font-family: Consolas; font-size: x-small;"><span style="color: maroon; font-family: Consolas; font-size: x-small;"><span style="color: maroon; font-family: Consolas; font-size: x-small;">'/_root/homepage.aspx?etc=10002&pagemode=iframe'</span></span></span><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;"><span style="color: silver; font-family: Consolas; font-size: x-small;">;</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"></end</span></span></span><span style="color: #3e60fd; font-family: Consolas; font-size: x-small;"><span style="color: #3e60fd; font-family: Consolas; font-size: x-small;"><span style="color: #3e60fd; font-family: Consolas; font-size: x-small;">script</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">></span></span></span></span><br />
<br />
<span style="background-color: yellow; color: grey; font-family: Consolas; font-size: x-small;">*Note: Replace the begin and endscript tags with script. Blogger apparently doesn't like that tag!</span><br />
<br />
<span style="background-color: white; color: black; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">However if I needed some silverlight or a webpage I can easily modify the ASPX page outside of CRM and not have to worry about importing. Using this method provides me enough abstraction to pretty much do what I want.</span><br />
<br />
<span style="font-family: Arial;">Tips about the code above:</span><br />
<ul><li><span style="font-family: Arial;">Using the CRM provided JS variables helps out tremendously. Familiarize yourself with them!</span></li>
<li><span style="font-family: Arial;">The pagemode=iframe parameter in the url will give you the correct view to show in the window.location. It removes the ribbon and anything else besides the core view.</span></li>
</ul>Ali Youssefihttp://www.blogger.com/profile/12576061374075857211noreply@blogger.com0