tag:blogger.com,1999:blog-72331863596909944182024-03-14T04:20:19.966+02:00Freelance Development for Dynamics CRMAnonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.comBlogger143125tag:blogger.com,1999:blog-7233186359690994418.post-14327203445092588372015-07-23T13:33:00.001+03:002015-08-07T16:54:07.413+03:00HowTo: Make CRM Developer Toolkit & ILMerge work togetherJust a quick note. Following post-build script automates merging of custom assemblies you’ve references in your code and the same time allows CRM Developer Toolkit to pick-up merged assembly for deployment:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">mkdir <span style="color: #006080;">"$(TargetDir)Merged"</span>
<span style="color: #006080;">"$(SolutionDir)ILMerge/ilmerge.exe"</span> /keyfile:<span style="color: #006080;">"$(ProjectDir)key.snk"</span> /target:library
/copyattrs /targetplatform:v4,<span style="color: #006080;">"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"</span>
/out:<span style="color: #006080;">"$(TargetDir)Merged\$(TargetFileName)"</span> <span style="color: #006080;">"$(TargetDir)$(TargetFileName)"</span>
<span style="color: #006080;">"$(TargetDir)Microsoft.Web.Services2.dll"</span> /lib:<span style="color: #006080;">"$(ProjectDir)bin\debug"</span>
del <span style="color: #006080;">"$(TargetDir)$(TargetFileName)"</span> /Q
move <span style="color: #006080;">"$(TargetDir)Merged\*.*"</span> <span style="color: #006080;">"$(TargetDir)"</span>
</pre>
<br /></div>
<br />
Of course to use it you have to point script to ILMerge executable, your strong name file and add assemblies you’ve used. Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-14418094540094337832015-07-22T20:19:00.001+03:002015-07-22T20:19:40.188+03:00HowTo: Avoid simultaneous execution of 2 instances of same workflow for a record<p>Let’s imagine that you (as a consultant) use waiting workflows (booo, I know that waiting workflows are evil). But let’s imagine and you have a field on a record that is responsible for datetime till when workflow has to wait to proceed. Obviously that change of a datetime field should lead to change of workflow “waiting to proceed” time. But you can’t apply this change to workflow that is triggered already. So to complete the task you have to kill existing instance of a workflow and run new. This article describes custom workflow activity that does the trick.</p><a name='more'></a> <div id="codeSnippetWrapper"><pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4">IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();<br>IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();<br>IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);<br><br><span style="color: #008000">//Retrieve processid of current workflow instance</span><br>Entity asyncOperation = service.Retrieve(<span style="color: #006080">"asyncoperation"</span>, <br> context.OperationId, <span style="color: #0000ff">new</span> Microsoft.Xrm.Sdk.Query.ColumnSet(<span style="color: #006080">"workflowactivationid"</span>));<br><br><span style="color: #008000">//Querying of waiting instances of workflow for current record except current one</span><br>QueryExpression asyncOperationsQuery = <span style="color: #0000ff">new</span> QueryExpression(<span style="color: #006080">"asyncoperation"</span>)<br>{<br> ColumnSet = <span style="color: #0000ff">new</span> ColumnSet(<span style="color: #0000ff">false</span>)<br>};<br>asyncOperationsQuery.Criteria.AddCondition(<span style="color: #006080">"asyncoperationid"</span>, ConditionOperator.NotEqual, asyncOperation.Id);<br>asyncOperationsQuery.Criteria.AddCondition(<span style="color: #006080">"workflowactivationid"</span>, ConditionOperator.Equal, <br> asyncOperation.GetAttributeValue<EntityReference>(<span style="color: #006080">"workflowactivationid"</span>).Id);<br>asyncOperationsQuery.Criteria.AddCondition(<span style="color: #006080">"statecode"</span>, ConditionOperator.Equal, 1);<br>asyncOperationsQuery.Criteria.AddCondition(<span style="color: #006080">"regardingobjectid"</span>, ConditionOperator.Equal, context.PrimaryEntityId);<br><br>Entity[] existingInstances = service.RetrieveMultiple(asyncOperationsQuery).Entities.ToArray();<br><br><span style="color: #008000">//Canelling</span><br><span style="color: #0000ff">foreach</span> (Entity existingInstance <span style="color: #0000ff">in</span> existingInstances)<br>{<br> existingInstance[<span style="color: #006080">"statecode"</span>] = <span style="color: #0000ff">new</span> OptionSetValue(3);<br> existingInstance[<span style="color: #006080">"statuscode"</span>] = <span style="color: #0000ff">new</span> OptionSetValue(32);<br><br> service.Update(existingInstance);<br>}<br></pre><br></div><br /><p></p>That’s pretty it. Copy Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-64816100371396243872015-03-11T21:56:00.001+02:002015-03-11T21:56:50.479+02:00Business Process Flow and Bulk Update of Process and StageLet’s imagine following situation – customer decided to use Business Process Flow for one of entities that already existed in CRM. You designed required BPF and everything looks great for new records. But what to do with existing records? Obvious answer is that you need somehow to update existing records. This article will show how to do it in easy and almost no-code way.<br />
<a name='more'></a>In my case customer used picklist with 4 values (Phase 1-4) to control stage of a record. Of course I knew that it would be possible to write code to update processid and stageid fields but we have amazing <a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-crm" target="_blank">SSIS Integration Toolkit</a> to do such kind of task. Here are steps:<br />
Open Visual Studio and Create “Integration Services Project”:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-FDIrQPhisQo/VQCcMlCq2QI/AAAAAAAACBo/iefL6la5o-E/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-FDIrQPhisQo/VQCcMlCq2QI/AAAAAAAACBo/iefL6la5o-E/s1600/2.png" height="219" width="320" /></a></div>
Add “Data Flow Task” to your project:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-Dr77OQX96os/VQCcMyuGVbI/AAAAAAAACB8/Mi8PbLuuePg/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-Dr77OQX96os/VQCcMyuGVbI/AAAAAAAACB8/Mi8PbLuuePg/s1600/3.png" height="126" width="320" /></a></div>
<br />
Open created Data Flow Task and add Dynamics CRM Source to Data Flow Task:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-DIMONVfZCoc/VQCcNP6nhEI/AAAAAAAACCU/SGIgLVcxs4I/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-DIMONVfZCoc/VQCcNP6nhEI/AAAAAAAACCU/SGIgLVcxs4I/s1600/4.png" height="183" width="320" /></a></div>
<br />
Configure connection to CRM and choose clause that would be used for data fetching (in my case I used Fetch Xml) – select field-pk of records would want to update and fields based on which you will decide with what stage particular record would be updated:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-caPsGSl9IVk/VQCcNi_2qqI/AAAAAAAACCM/ne-47Fm1U1U/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-caPsGSl9IVk/VQCcNi_2qqI/AAAAAAAACCM/ne-47Fm1U1U/s1600/5.png" height="239" width="320" /></a></div>
<br />
Add “Derived Column” to Data Flow Task to add identifier of BPF:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-ErLiR5H3CrY/VQCcNzedzaI/AAAAAAAACCA/R5R5B8UcgTA/s1600/6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-ErLiR5H3CrY/VQCcNzedzaI/AAAAAAAACCA/R5R5B8UcgTA/s1600/6.png" height="99" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/--9UBIG5uTFQ/VQCcOoNrLYI/AAAAAAAACCQ/-LE_eRJgPps/s1600/7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/--9UBIG5uTFQ/VQCcOoNrLYI/AAAAAAAACCQ/-LE_eRJgPps/s1600/7.png" height="153" width="320" /></a></div>
<br />
Add “Script Component” of type Transformation to add identifier of stage of BPF:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-hczNRF9iAkI/VQCcO7sN6YI/AAAAAAAACCY/L--5rkViozo/s1600/8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-hczNRF9iAkI/VQCcO7sN6YI/AAAAAAAACCY/L--5rkViozo/s1600/8.png" height="161" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-85KFlb3z-As/VQCcJBWOtWI/AAAAAAAACBM/34MnSYrH6tM/s1600/10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-85KFlb3z-As/VQCcJBWOtWI/AAAAAAAACBM/34MnSYrH6tM/s1600/10.png" height="276" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-uI5LX6KJnfg/VQCcJbXMmlI/AAAAAAAACC8/m1zjmLGIthM/s1600/11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-uI5LX6KJnfg/VQCcJbXMmlI/AAAAAAAACC8/m1zjmLGIthM/s1600/11.png" height="276" width="320" /></a></div>
<br />
Use following code in Script Component:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> Input0_ProcessInputRow(Input0Buffer Row)
{
<span style="color: blue;">string</span> result = <span style="color: blue;">null</span>;
<span style="color: blue;">switch</span> (Row.newopportunityphase)
{
<span style="color: blue;">case</span> 100000000:
result = <span style="color: #006080;">"6234178d-4cad-4aa5-8b10-3b7e84c16829"</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> 100000001:
result = <span style="color: #006080;">"9223b6b6-ad31-a242-9128-19303819c123"</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> 100000002:
result = <span style="color: #006080;">"c0481a30-8500-7230-7632-0d8d17aad035"</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> 100000003:
result = <span style="color: #006080;">"5d6e8351-6456-6c52-3648-2676e760627b"</span>;
<span style="color: blue;">break</span>;
}
Row.stageid = result;
}</pre>
<br /></div>
<br />
Save and add “Dynamics CRM Destination” component:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-P81J4Iaw-6s/VQCcJTgujpI/AAAAAAAACDA/vT6UKCFcy2o/s1600/12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-P81J4Iaw-6s/VQCcJTgujpI/AAAAAAAACDA/vT6UKCFcy2o/s1600/12.png" height="232" width="320" /></a></div>
<br />
Configure connection to CRM, choose action, entity and map fields for update:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-IkdkiKmIIgs/VQCcK9z-WeI/AAAAAAAACC4/rXCPbz3m8hk/s1600/13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-IkdkiKmIIgs/VQCcK9z-WeI/AAAAAAAACC4/rXCPbz3m8hk/s1600/13.png" height="197" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-CO9yvZaxYdY/VQCcLEdH17I/AAAAAAAACC0/E1F_NsGM2o0/s1600/14.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-CO9yvZaxYdY/VQCcLEdH17I/AAAAAAAACC0/E1F_NsGM2o0/s1600/14.png" height="197" width="320" /></a></div>
<br />
So that’s it and now we can update data:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-FXXD4L_Oey8/VQCcLc59VDI/AAAAAAAACCw/R1f28nux-qU/s1600/15.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-FXXD4L_Oey8/VQCcLc59VDI/AAAAAAAACCw/R1f28nux-qU/s1600/15.png" height="320" width="234" /></a></div>
<br />
Lets imagine reverse scenario – BPF existed for entity and customer decided to turn it off and remove from a system. After you will deactivate all BPFs and for new records BPF bar would not appear you will see that for existing record it is still available. Solution – clean processid and stageid fields for existing records. Steps would be almost the same as in previous sample with little difference:<br />
<br />
“Derived Column”:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-tov5y-T3mh0/VQCcL3Bio8I/AAAAAAAACCo/Ge3arwOGpNc/s1600/16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-tov5y-T3mh0/VQCcL3Bio8I/AAAAAAAACCo/Ge3arwOGpNc/s1600/16.png" height="172" width="320" /></a></div>
<br />
No need in script component – just add “Dynamics CRM Destination”:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-EK2xGJlLAxc/VQCcMLfW3HI/AAAAAAAACCk/eeyASPZJ4UA/s1600/17.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-EK2xGJlLAxc/VQCcMLfW3HI/AAAAAAAACCk/eeyASPZJ4UA/s1600/17.png" height="320" width="286" /></a></div>
That's it. Once you've ran DTS identifiers of process and stage would be cleaned.Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com1tag:blogger.com,1999:blog-7233186359690994418.post-71193457242456817152015-03-01T05:39:00.000+02:002015-03-02T19:59:28.064+02:00HowTo: HTML/JS WebResourcesWe (developers) have got great feature with CRM 2011 release. If you want to give your CRM application new client side features or controls that are not available OOB on one hand and you want your solution remain supported you have to use HTML/JS webresources. This article will describe approaches, tricks and code snippets I’ve fount or developed during my usage of HTML/JS webresources.<br />
<a name='more'></a><br />
<a href="https://www.blogger.com/null" name="more"></a><b>Embedding and passing parameters</b><br />
To pass context of execution (entity and identifier or a record) or some custom parameters you have to define it in webresource configuration:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-QW9pPyQ-0TE/VPKHd5cEmEI/AAAAAAAAB_o/mZ7-I-Z1eJM/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-QW9pPyQ-0TE/VPKHd5cEmEI/AAAAAAAAB_o/mZ7-I-Z1eJM/s1600/1.png" height="320" width="287" /></a></div>
<br />
To parse and use parameters in your webresource you can use following code:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> parameters = GetGlobalContext().getQueryStringParameters();</pre>
<br /></div>
<span style="color: red;">Important Note: to make GetGlobalContext method available you have to reference ClientGlobalContext.js.aspx in your code:</span><br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="../ClientGlobalContext.js.aspx"</span><span style="color: blue;">></</span><span style="color: maroon;">script</span><span style="color: blue;">></span></pre>
<br /></div>
<br />
And here is how passed parameters could be used:<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-H2nbk_jd64o/VPKHd99Yc7I/AAAAAAAAB_8/gdMLEL7JRyU/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-H2nbk_jd64o/VPKHd99Yc7I/AAAAAAAAB_8/gdMLEL7JRyU/s1600/2.png" height="151" width="320" /></a></div>
<br />
So to get identifier or type of a record you can use following code:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> recordid = parameters.id;
<span style="color: blue;">var</span> entityname = parameters.typename;</pre>
<br /></div>
<br />
Obviously in case parameters.id equals to null that means that user creates a record or you haven’t checked ‘Pass record object-type code and unique identifier as parameters.’ checkbox. So if you are sure that you have checked the checkbox and id is null that means that webresource is executed in a context of create form.<br />
<br />
In case you have added custom parameter or parameters you can access to it using following code:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> customparams = parameters.data;</pre>
<br /></div>
<br />
In case you use multiple parameters and you use format “Parameter1=Value1&Parameter2=Value2” following code could help you in parsing of parameters passed:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">function</span> ParseData(query) {
<span style="color: blue;">var</span> result = {};
<span style="color: blue;">if</span> (<span style="color: blue;">typeof</span> query == <span style="color: #006080;">"undefined"</span> || query == <span style="color: blue;">null</span>) {
<span style="color: blue;">return</span> result;
}
<span style="color: blue;">var</span> queryparts = query.split(<span style="color: #006080;">"&"</span>);
<span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i < queryparts.length; i++) {
<span style="color: blue;">var</span> <span style="color: blue;">params</span> = queryparts[i].split(<span style="color: #006080;">"="</span>);
result[<span style="color: blue;">params</span>[0]] = <span style="color: blue;">params</span>.length > 1 ? <span style="color: blue;">params</span>[1] : <span style="color: blue;">null</span>;
}
<span style="color: blue;">return</span> result;
}</pre>
<br /></div>
<br />
and here is usage of mentioned method:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> customparams = ParseData(parameters.data);
<span style="color: blue;">var</span> customparam1 = customparams.CustomParam1;
<span style="color: blue;">var</span> customparam2 = customparams.CustomParam2;</pre>
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-HjXLSsi6L2M/VPKHd2mDHyI/AAAAAAAAB_s/_Bdqq1zjgXo/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-HjXLSsi6L2M/VPKHd2mDHyI/AAAAAAAAB_s/_Bdqq1zjgXo/s1600/3.png" height="73" width="320" /></a></div>
<br />
<span style="color: red;">UPD:</span> Today I have got brilliant suggestion from <a href="http://mvp.microsoft.com/en-us/mvp/Artem%20Grunin-5000812" target="_blank">my friend and MVP Artem Grunin</a> – try to use JSON format when you pass custom parameters. I tried and here are results I’ve got:<br />
<br />
Registration of custom parameters:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-IAvNpznEqPg/VPSU3mFOUCI/AAAAAAAACAo/RHzadxXDwSI/s1600/6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-IAvNpznEqPg/VPSU3mFOUCI/AAAAAAAACAo/RHzadxXDwSI/s1600/6.png" height="111" width="320" /></a></div>
And usage in webresource code:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-d8SPJrwKlN0/VPSU3s4GxvI/AAAAAAAACAs/7k2uH8dYWSg/s1600/7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-d8SPJrwKlN0/VPSU3s4GxvI/AAAAAAAACAs/7k2uH8dYWSg/s1600/7.png" height="109" width="320" /></a></div>
<br />
<br />
As you can see – that work perfectly!<br />
<br />
<b>Communication with caller window</b><br />
<br />
In case you need to communicate with caller window you can use following code to get “Xrm” object:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> Xrm = window.parent.Xrm;</pre>
<br /></div>
<br />
and after access to everything that is available for usual JavaScript code for CRM form. For example getting of field value:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> windownamefieldvalue = Xrm.Page.getAttribute(<span style="color: #006080;">"new_name"</span>).getValue();</pre>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-W7vLww3EI_k/VPKHelorBVI/AAAAAAAAB_0/wTtTPFYezpI/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-W7vLww3EI_k/VPKHelorBVI/AAAAAAAAB_0/wTtTPFYezpI/s1600/4.png" height="72" width="320" /></a></div>
<br />
<br />
<b>Subscription to fields and form events</b><br />
<br />
Sometimes you need to react on some events that is raised in CRM form like OnChange of field or OnSave of form. You can do it using following code for OnChange:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> Xrm = window.parent.Xrm;
Xrm.Page.getAttribute(<span style="color: #006080;">"new_name"</span>).addOnChange(<span style="color: blue;">function</span> (context) {
alert(<span style="color: #006080;">"Field Was Changed"</span>);
});</pre>
<br /></div>
<br />
<br />
“context” parameter of a method could be used to get information about call context. Here is short code that demonstrates how it could be used:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> Xrm = window.parent.Xrm;
Xrm.Page.getAttribute(<span style="color: #006080;">"new_name"</span>).addOnChange(<span style="color: blue;">function</span> (context) {
<span style="color: blue;">var</span> originAttribute = context.getEventSource();<span style="color: green;">//Attribute that was changed on a form.</span>
<span style="color: blue;">var</span> callDepth = context.getDepth();<span style="color: green;">//get depth of a call.</span>
alert(<span style="color: #006080;">"Attribute "</span> + originAttribute.getName() + <span style="color: #006080;">" was changed and depth of a call is "</span> + callDepth);
});</pre>
<br /></div>
<br />
<br />
In case you need to handle OnSave event you can use following code:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> Xrm = window.parent.Xrm;
Xrm.Page.data.entity.addOnSave(<span style="color: blue;">function</span> (context) {
alert(<span style="color: #006080;">"Form was saved"</span>);
});</pre>
<br /></div>
<br />
”context” parameter is a standard execution context for Save event we use in standard CRM forms. You can use it to analyze Save mode or cancel Save:<br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> Xrm = window.parent.Xrm;
Xrm.Page.data.entity.addOnSave(<span style="color: blue;">function</span> (context) {
alert(<span style="color: #006080;">"Form was saved and Save mode is - "</span> + context.getEventArgs().getSaveMode());
context.getEventArgs().preventDefault();
alert(<span style="color: #006080;">"Save was cancelled"</span>);
});</pre>
<br /></div>
<br />
<b>Tricks</b><br />
<br />
<span style="color: black;"><b>Fixing behavior of webresources for which execution logic for Create and Update forms differs (special thanks to Inogic for the idea, origin - <a href="http://inogic.com/blog/2014/08/update-html-on-form-save-button/" title="http://inogic.com/blog/2014/08/update-html-on-form-save-button/">http://inogic.com/blog/2014/08/update-html-on-form-save-button/</a>)</b></span><br />
<br />
<span style="color: black;">Let’s assume that you have developed webresource for which execution logic is different for Create and Update form. You have opened new form and in this case webresource worked properly (followed ‘Create Form’ logic). You clicked Save and expected that webresource would be reloader and ‘Update Form’ logic would work. Unfortunately not. CRM doesn’t reload webresources in such scenarios. Add following code to CRM Form Onload handler to help CRM reload webresource:</span><br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> wrid = <span style="color: #006080;">"Put your webresource control here"</span>;
<span style="color: blue;">var</span> currenturl = Xrm.Page.getControl(wrid).getSrc();
<span style="color: blue;">if</span> (currenturl.toLowerCase() == <span style="color: #006080;">"/_static/blank.htm"</span>) {
currenturl = Xrm.Page.getControl(wrid).getInitialUrl();
}
<span style="color: blue;">if</span> (currenturl.toLowerCase().indexOf(<span style="color: #006080;">"id="</span>, currenturl.length() - 3) != -1) {
currenturl += Xrm.Page.data.entity.getId();
Xrm.Page.getControl(wrid).setSrc(currenturl);
}</pre>
<br /></div>
<br />
<span style="color: black;"><b>Restore of standard events (special thanks to Spectr, origin - <a href="http://axforum.info/forums/showthread.php?p=301306#post301306" title="http://axforum.info/forums/showthread.php?p=301306#post301306">http://axforum.info/forums/showthread.php?p=301306#post301306</a>)</b></span><br />
<br />
<span style="color: black;">If you have referenced ClientGlobalContext.js.aspx you should aware that this would cancel the <a href="https://msdn.microsoft.com/en-us/library/ie/ms536969%28v=vs.85%29.aspx">onselectstart</a>, <a href="https://msdn.microsoft.com/en-us/library/ie/ms536914%28v=vs.85%29.aspx">contextmenu</a>, and <a href="https://msdn.microsoft.com/en-us/library/ie/ms536928%28v=vs.85%29.aspx">ondragstart</a> events. In case you want to restore those handlers you can use following code during onload of webresource:</span><br />
<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">if</span> (document &&
document._events &&
document._events.unload &&
document._events.unload[0] &&
document._events.unload[0].handler) {
document._events.unload[0].handler();
}</pre>
<br /></div>
<br />
<br />
<span style="color: black;"><b>General Conclusions</b></span><br />
<br />
<span style="color: black;">1. Try to use supported approaches otherwise your code could stop working after installation of Updates</span><br />
<br />
<span style="color: black;">2. In case you want to build complex and beautiful extensions start learning (if you haven’t yet) JavaScript Frameworks. Here is what I use at the moment:</span><br />
<br />
<ul><br />
<li><span style="color: black;"><a href="http://jquery.com/" target="_blank">jQuery</a> (for easier work with DOM)</span> </li>
<li><span style="color: black;"><a href="http://knockoutjs.com/" target="_blank">Knockout.js</a> (for complex binding scenarios)</span></li>
</ul>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-71639094895660632352015-01-07T08:14:00.003+02:002015-01-07T08:14:50.599+02:00HowTo: Open standard lookup window and get selected record(s)<div style="text-align: justify;">
If you are apologist of 100% supported solutions for Dynamics CRM this is a good place to close this article because it describes approach that will allow to open standard lookup dialog window of CRM and get selected values from it. <span style="color: red;">Of course that customization is unsupported.</span></div>
<a name='more'></a>To use standard lookup control you can use following code:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">function</span> OpenLookup() {
<span style="color: blue;">var</span> lookupurl = <span style="color: #006080;">"/_controls/lookup/lookupinfo.aspx?"</span> +
<span style="color: #006080;">"AllowFilterOff=0&DefaultType=2&DisableQuickFind=0&DisableViewPicker=0&IsInlineMultiLookup=0"</span> +
<span style="color: #006080;">"&LookupStyle=single&ShowNewButton=1&ShowPropButton=1&browse=false&objecttypes=2"</span>;
<span style="color: blue;">var</span> dialogwindow = <span style="color: blue;">new</span> Mscrm.CrmDialog(Mscrm.CrmUri.create(lookupurl), window, 500, 500);
dialogwindow.setCallbackReference(<span style="color: blue;">function</span> (result) {
alert(result.items.length + <span style="color: #006080;">" records were selected"</span>);
<span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i < result.items.length; i++) {
alert(result.items[i].typename + <span style="color: #006080;">" with name "</span> + result.items[i].name + <span style="color: #006080;">" and id "</span> + result.items[i].id + <span style="color: #006080;">" was selected in lookup"</span>);
}
});
dialogwindow.show();
}</pre>
<br /></div>
<br />
<div style="text-align: justify;">
In this sample after OpenLookup function was called user will get single contact lookup form opened with all controls available like view dropdown, quick find box, new and properties button. In case you want to customize lookup window you can play with parameters from url.In case you will use this script in your Html webresource don’t forget to add reference to ClientGlobalContext.js.aspx.</div>
<br />
<div style="text-align: justify;">
<span style="color: red;">I’ve tested this approach for CRM 2013 and 2015. In case it doesn’t work – that means that you’ve done something wrong or this approach is not available because it is not supported ;)</span></div>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-23591909599540107732015-01-03T16:22:00.001+02:002015-01-03T16:22:31.642+02:00MVP Renewed – 5<p>Sixth year in a row I have got MVP award. Congratulations to all MVP's who has got award first time or was re-awarded.</p> Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-4495561195503478842014-12-25T10:14:00.001+02:002014-12-25T10:14:48.947+02:00Microsoft CRM 2015 and OData queries builders<p>Since OData endpoint was released with CRM 2011 I used <a href="https://crm2011odatatool.codeplex.com/" target="_blank">CRM OData Query Designer</a> developed by <a href="https://bingsoft.wordpress.com/" target="_blank">MVP fellow Rhett Clinton</a>. Today I was working on brand new online instance of CRM 2015 and… I was not able to import lovely tool into CRM with message that solutions developed for CRM 2011 could not be imported into CRM 2015. I started to look for alternatives and found brilliant solution developed by other MVP fellow – <a href="http://jlattimer.blogspot.com/" target="_blank">Jason Lattimer</a>. The great advantage of CRM REST Builder is that you can get complete code of calls using different frameworks developed for Dynamics CRM. So try, use and love this tool – <a href="https://crmrestbuilder.codeplex.com/" target="_blank">CRM REST Builder</a>.</p> Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-63962037248469260952014-10-08T17:59:00.004+03:002014-10-08T18:00:05.733+03:00Microsoft CRM 2013: Currency exchange rates actualizationIn this article I will share with small add-on I developed for one of my customers.<br />
Let’s assume that you are employee of company that uses CRM with several currencies. Of course you want to have actual information in your system and currency exchange rates should be current. Microsoft CRM allows to have in system one base currency and many other currencies. Every currency has exchange rate field that is used for calculation of base fields of your currency fields but there is no out-of-box possibility to actualize exchange rates.<br />
<a name='more'></a>I have added to my CRM system several currencies:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-OHa-PsWHnaA/VDVQqQYox1I/AAAAAAAAB-o/_XQNI3vXksg/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-OHa-PsWHnaA/VDVQqQYox1I/AAAAAAAAB-o/_XQNI3vXksg/s1600/1.png" height="120" width="320" /></a></div>
<br />
Using my add-on you can keep your currency exchange rates up-to-date:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-qjzpDvGYNgw/VDVQqehO9KI/AAAAAAAAB-8/t7HtvF9-rcE/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-qjzpDvGYNgw/VDVQqehO9KI/AAAAAAAAB-8/t7HtvF9-rcE/s1600/2.png" height="119" width="320" /></a></div>
<br />
Usage of addon is simple:<br />
1. Download solution: <br />
<iframe frameborder="0" height="120" scrolling="no" src="https://onedrive.live.com/embed?cid=F63E4BCD4A7F64A4&resid=F63E4BCD4A7F64A4%211527&authkey=AHqN0j907lWceiU" width="98"></iframe><iframe frameborder="0" height="120" scrolling="no" src="https://onedrive.live.com/embed?cid=F63E4BCD4A7F64A4&resid=F63E4BCD4A7F64A4%211526&authkey=AAhz8bz8ldpN3mA" width="98"></iframe><br />
2. Import it to CRM (in case you will download and import unmanaged solution you will have to publish solution and activate workflow). <br />
3. Open Settings – Sync Schedules (this is custom entity that is the part of solution) and create new Sync Schedule record, fill Next Execution DateTime field (for example midnight of your current day): <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-aR3w--fZSF8/VDVQqV8OVmI/AAAAAAAAB_Q/iXMnY6IugEQ/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-aR3w--fZSF8/VDVQqV8OVmI/AAAAAAAAB_Q/iXMnY6IugEQ/s1600/3.png" height="65" width="320" /></a></div>
<br />
4. Run Sync Currency Exchange Rates workflow against your Sync Schedule record that you’ve created on previous step:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-xqPqGJazRcA/VDVQq5LeUzI/AAAAAAAAB_c/cfhXB8aUDaQ/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-xqPqGJazRcA/VDVQq5LeUzI/AAAAAAAAB_c/cfhXB8aUDaQ/s1600/4.png" height="146" width="320" /></a><a href="http://3.bp.blogspot.com/-m-BxHG3fwUo/VDVQrDwsiKI/AAAAAAAAB_E/uMmf_jQW_qw/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-m-BxHG3fwUo/VDVQrDwsiKI/AAAAAAAAB_E/uMmf_jQW_qw/s1600/5.png" height="317" width="320" /></a></div>
<br />
<br />
Wait till workflow would be executed and go to currencies to check that currency exchange rates were updated:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-qjzpDvGYNgw/VDVQqehO9KI/AAAAAAAAB-8/t7HtvF9-rcE/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-qjzpDvGYNgw/VDVQqehO9KI/AAAAAAAAB-8/t7HtvF9-rcE/s1600/2.png" height="119" width="320" /></a></div>
<br />
Here is screenshot of workflow I’ve designed:<br />
Logic of workflow is really simple:<br />
<ol>
<li>Wait till the next execution date. </li>
<li>Update Currency exchange rates. </li>
<li>Update next execution date as current plus 1 day and this will invoke recurrent execution of workflow.</li>
</ol>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-3qEmewL8Jto/VDVQrmSktEI/AAAAAAAAB_I/BfXUkbxNo04/s1600/6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-3qEmewL8Jto/VDVQrmSktEI/AAAAAAAAB_I/BfXUkbxNo04/s1600/6.png" height="206" width="320" /></a><a href="http://2.bp.blogspot.com/-4UzO0RSRmuI/VDVQsGbS-JI/AAAAAAAAB_M/q5kL7sAr82c/s1600/7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-4UzO0RSRmuI/VDVQsGbS-JI/AAAAAAAAB_M/q5kL7sAr82c/s1600/7.png" height="102" width="320" /></a></div>
<br />
PS I used <a href="http://www.webservicex.net/CurrencyConvertor.asmx" title="http://www.webservicex.net/CurrencyConvertor.asmx">http://www.webservicex.net/CurrencyConvertor.asmx</a> webservice for getting of actual exchange rates.Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-41702316338959063762014-09-27T19:12:00.000+03:002014-09-27T19:12:32.035+03:00Reporting for Dynamics CRM: Error while loading code module: “Microsoft.Crm.Reporting.RdlHelper…”Let’s assume that you’ve created report for Dynamics CRM using Report Wizard and opened it with BIDS to add changes that are not available with Report Wizard (it could be anything – adding of images, change of fonts or layout…).<br />
Once you’ve opened a report and applied change of course you want to recheck changes. In case you will get error that is shown on following screenshot you can find steps that will allow to build and test report in BIDs without any issues:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-QZBftB8vDoA/VCbhQoArZ1I/AAAAAAAAB-I/rc4lnDbomXk/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-QZBftB8vDoA/VCbhQoArZ1I/AAAAAAAAB-I/rc4lnDbomXk/s1600/1.png" height="55" width="320" /></a></div>
<br />
<a name='more'></a>Return back to design mode, open Report – Report Properties.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-eLUAjImhH60/VCbhQgdTnSI/AAAAAAAAB-Y/C6ag-6-WOyo/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-eLUAjImhH60/VCbhQgdTnSI/AAAAAAAAB-Y/C6ag-6-WOyo/s1600/2.png" height="79" width="320" /></a></div>
<br />
Open References tab and change reference of assembly to existing on your PC.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-YX_aV90426M/VCbhQpNaPTI/AAAAAAAAB-U/90fd1i-Z2lk/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-YX_aV90426M/VCbhQpNaPTI/AAAAAAAAB-U/90fd1i-Z2lk/s1600/3.png" height="246" width="320" /></a></div>
<br />
PS you can download required assemby here:<br />
<iframe frameborder="0" height="120" scrolling="no" src="https://onedrive.live.com/embed?cid=F63E4BCD4A7F64A4&resid=F63E4BCD4A7F64A4%211508&authkey=AF21ymL5G4Ik0tM" width="98"></iframe>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-47101900186227984232014-06-13T03:54:00.000+03:002014-06-13T03:56:21.293+03:00Dynamics CRM 2013: Step-by-step creating dialog windowsIn my previous post I shared how to use Microsoft CRM internal function to show dialog window in Dynamics CRM 2013 inline style. In this post I will write step-by-step guide how to build own dialogs in CRM 2013 style.<br />
<a name='more'></a>Let’s assume that we’ve build html webresource and want to call it. Following code will help you to do that:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: green;">//Passing parameters to webresource</span>
<span style="color: blue;">var</span> addParams = <span style="color: #006080;">"Param1="</span> + param1 + <span style="color: #006080;">"&Param2="</span> + param2;
<span style="color: blue;">var</span> webresourceurl = <span style="color: #006080;">"/webresources/new_/webresource.htm?Data="</span> + encodeURIComponent(addParams);
<span style="color: green;">//If you don't need to pass any parameters use following code instead:</span>
<span style="color: green;">//var webresourceurl = "/webresources/new_webresource.htm";</span>
<span style="color: green;">//First parameter - prepared url of dialog</span>
<span style="color: green;">//Second parameter - control from which you open dialog</span>
<span style="color: green;">//Third and Fourth - width and height</span>
<span style="color: blue;">var</span> dialogwindow = <span style="color: blue;">new</span> Mscrm.CrmDialog(Mscrm.CrmUri.create(webresourceurl), window, 500, 500);
<span style="color: green;">//use setCallbackReference method to call some handler once dialog is closed</span>
<span style="color: green;">//to result variable would be returned result of dialog call</span>
dialogwindow.setCallbackReference(<span style="color: blue;">function</span> (result) { alert(result) });
<span style="color: green;">//call this method to show dialog</span>
dialogwindow.show();</pre>
<br /></div>
<br />
<br />
Take this sample code adapt it to your needs and use. Following part is related to building of dialog.<br />
<br />
If you used parameters during the call of dialog you can use following helper method to get values of parameters:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">function</span> ParseQueryString(query) {
<span style="color: blue;">var</span> result = {};
<span style="color: blue;">if</span> (<span style="color: blue;">typeof</span> query == <span style="color: #006080;">"undefined"</span> || query == <span style="color: blue;">null</span>) {
<span style="color: blue;">return</span> result;
}
<span style="color: blue;">var</span> queryparts = query.split(<span style="color: #006080;">"&"</span>);
<span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i < queryparts.length; i++) {
<span style="color: blue;">var</span> <span style="color: blue;">params</span> = queryparts[i].split(<span style="color: #006080;">"="</span>);
result[<span style="color: blue;">params</span>[0]] = <span style="color: blue;">params</span>.length > 1 ? <span style="color: blue;">params</span>[1] : <span style="color: blue;">null</span>;
}
<span style="color: blue;">return</span> result;
}</pre>
<br /></div>
<br />
<br />
To get parameters you can use following code:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">var</span> passedparams = ParseQueryString(GetGlobalContext().getQueryStringParameters()[<span style="color: #006080;">"Data"</span>]);
alert(passedparams.Param1);
alert(passedparams.Param2);</pre>
<br /></div>
<br />
Here is the code of whole dialog page:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;"><</span><span style="color: maroon;">html</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">head</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">title</span><span style="color: blue;">></</span><span style="color: maroon;">title</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="../ClientGlobalContext.js.aspx"</span><span style="color: blue;">></</span><span style="color: maroon;">script</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">style</span> <span style="color: red;">type</span><span style="color: blue;">="text/css"</span><span style="color: blue;">></span>
body
{
direction: LTR;
margin: 0px;
border: 0px;
cursor: default;
font-family: Segoe UI,Tahoma,Arial;
font-size: 11px;
}
.ms-crm-RefreshDialog-Header
{
top: 0px;
position: absolute;
width: 96%;
height: 75px;
padding-top: 10px;
background-color: #FFFFFF;
border-bottom-color: #A4ABB2;
}
DIV.ms-crm-RefreshDialog-Header-Title
{
font-weight: Lighter;
font-size: 27px;
font-family: Segoe UI Light, Segoe UI, Tahoma, Arial;
margin-left: 30px;
margin-right: 30px;
color: #262626;
}
.ms-crm-TextAutoEllipsis
{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ms-crm-RefreshDialog-Header-Desc
{
padding-top: 4px;
font-family: Segoe UI,Tahoma,Arial;
margin-left: 30px;
margin-right: 30px;
color: #666666;
font-size: 12px;
}
.ms-crm-RefreshDialog-Main
{
font-size: 12px;
top: 90px;
position: absolute;
bottom: 49px;
vertical-align: top;
width: 95%;
font-family: Segoe UI,Tahoma,Arial;
color: #444444;
background-color: #FFFFFF;
border-bottom-color: #A4ABB2;
right: 30px;
left: 30px;
}
.ms-crm-RefreshDialog-Footer
{
position: absolute;
bottom: 0px;
width: 100%;
min-width: 288px;
height: 44px;
text-align: right;
background-color: #F8F8F8;
border-top-color: #FFFFFF;
}
.ms-crm-RefreshDialog-Button
{
color: #444444;
background-color: #FFFFFF;
height: 24px;
font-family: Segoe UI,Tahoma,Arial;
border: 1px solid #C6C6C6;
background-image: none;
margin-top: 10px;
width: auto;
min-width: 80px;
white-space: nowrap;
font-size: 12px;
line-height: 16px;
width: 84px;
text-align: center;
cursor: pointer;
background-repeat: repeat-x;
padding-left: 5px;
padding-right: 5px;
}
<span style="color: blue;"></</span><span style="color: maroon;">style</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">head</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">body</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Main-Container"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Header"</span> <span style="color: red;">id</span><span style="color: blue;">="tdDialogHeader"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">id</span><span style="color: blue;">="dialogHeaderTitle"</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Header-Title ms-crm-TextAutoEllipsis"</span>
<span style="color: red;">title</span><span style="color: blue;">="Your dialog header"</span> <span style="color: red;">style</span><span style="color: blue;">="width: 75%;"</span><span style="color: blue;">></span>Your dialog header<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">id</span><span style="color: blue;">="dialogHeaderDesc"</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Header-Desc"</span>
<span style="color: red;">title</span><span style="color: blue;">="Your dialog additional description"</span><span style="color: blue;">></span>Your dialog additional description<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">id</span><span style="color: blue;">="DlgHdBodyContainer"</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Main"</span><span style="color: blue;">></span>
Put your controls here
<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Footer"</span> <span style="color: red;">id</span><span style="color: blue;">="tdDialogFooter"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">button</span> <span style="color: red;">id</span><span style="color: blue;">="btnOK"</span> <span style="color: red;">onclick</span><span style="color: blue;">="Mscrm.Utilities.setReturnValue(true); closeWindow();"</span> <span style="color: red;">type</span><span style="color: blue;">="button"</span>
<span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Button"</span> <span style="color: red;">tabindex</span><span style="color: blue;">="1"</span> <span style="color: red;">style</span><span style="color: blue;">="margin-left: 8px;"</span><span style="color: blue;">></span>OK<span style="color: blue;"></</span><span style="color: maroon;">button</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">button</span> <span style="color: red;">id</span><span style="color: blue;">="cmdDialogCancel"</span> <span style="color: red;">onclick</span><span style="color: blue;">="closeWindow();"</span> <span style="color: red;">type</span><span style="color: blue;">="button"</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-RefreshDialog-Button"</span>
<span style="color: red;">tabindex</span><span style="color: blue;">="1"</span> <span style="color: red;">style</span><span style="color: blue;">="margin-left: 8px; margin-right: 30px"</span><span style="color: blue;">></span>Cancel<span style="color: blue;"></</span><span style="color: maroon;">button</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">body</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">html</span><span style="color: blue;">></span></pre>
<br /></div>
<br />
Here are several tips:<br />
<br />
1. Remember regarding location of ClientGlobalContext.js.aspx relatively to your webresource.<br />
<br />
2. In case you want to return something to callback function you’ve declared during call of dialog – use snippet from btnOK button:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">Mscrm.Utilities.setReturnValue(ValueToPass);</pre>
<br /></div>
3. If you want to close dialog from your dialog controls just call closeWindow method.<br />
<br />
All of this information I have got during building simple dialog that is shown on following picture (function – possibility to merge Sales Orders that is not available out-of-box):<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-SAJ5SWqWClY/U5pLxZdLreI/AAAAAAAAB9Y/Gc_O_t1l3eI/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-SAJ5SWqWClY/U5pLxZdLreI/AAAAAAAAB9Y/Gc_O_t1l3eI/s1600/1.png" height="168" width="320" /></a></div>
<br />
<span style="color: red;">All provided scripts and approaches are not recommended because internal CRM methods are used and your code could be broken in case any of used methods would be changed during installation of updates. </span>Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-62917168582699654852014-05-26T08:22:00.001+03:002014-05-26T08:22:32.044+03:00Show your dialog in CRM 2013 modal style<div id="codeSnippetWrapper">
With CRM 2013 we have got one working window without any pop-up windows (lookups, dialogs, e.t.c.). But… only for standard features. What to do in case you wanted to use the same approach with modal windows as CRM does it? I walked through SDK and found following article - <a href="http://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource" title="http://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource">http://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource</a>. I tried the code but I have got wrapped window.open method. After some investigations I found how CRM does it:</div>
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">if</span> (typeof Custom == "undefined") {
Custom = {
OpenDialog: <span style="color: blue;">function</span> (webresource) {
var $v_0 = <span style="color: blue;">new</span> Mscrm.CrmDialog(Mscrm.CrmUri.<span style="color: blue;">create</span>(webresource), window, 370, 370, <span style="color: blue;">null</span>);
$v_0.show();
},
__namespace: <span style="color: blue;">true</span>
};
}</pre>
<br />
<br />
and usage is following:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">Custom.OpenDialog("/webresources/new_webresource.htm");</pre>
<br /></div>
Demonstration of how it looks like:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-dDyJFg4KC-I/U4LPfuqgfWI/AAAAAAAAB9E/6vSFeXu6piY/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-dDyJFg4KC-I/U4LPfuqgfWI/AAAAAAAAB9E/6vSFeXu6piY/s1600/1.png" height="176" width="320" /></a></div>
<br />
<br />
You can use this approach but remember that this code uses undocumented methods so it could be broken with any rollup.Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-16945676989218268782014-02-18T02:02:00.001+02:002014-02-18T02:02:45.771+02:00MVP – 2At least I have received all packages from Microsoft and put all parts together. It looks awesome:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-dyuKzGlnAV8/UwKjA2kv2UI/AAAAAAAAB8k/FsPHNW_ACtA/s1600/IMG_0904.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-dyuKzGlnAV8/UwKjA2kv2UI/AAAAAAAAB8k/FsPHNW_ACtA/s1600/IMG_0904.jpg" height="320" width="247" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-57140418102529874422014-02-10T06:53:00.001+02:002014-02-10T06:53:37.480+02:00MS CRM 2013: OOB BingMaps control shows ‘click here to view map’ – what to do?<span style="color: red;">This article can help you to activate this feature for On Premise deployment only! This would not work for Online!</span><br />
<span style="color: black;">If you see something similar when you open your CRM Organization that means that for some reason MS decided to limit your possibility to see location of contact, account or other record on map:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-UXvYhENBmWE/UvhbEaUAdjI/AAAAAAAAB8M/kPk0og7rSwg/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-UXvYhENBmWE/UvhbEaUAdjI/AAAAAAAAB8M/kPk0og7rSwg/s1600/1.png" height="136" width="320" /></a></div>
<span style="color: black;"><br /></span>
<span style="color: black;">To fix it do following steps:</span><br />
<span style="color: black;">1. Connect to SQL Server where DBs are located.</span><br />
<span style="color: black;">2. Open SQL Management Studio and execute following query against your CRM DB:</span><br />
<span style="color: black;"><br /></span>
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">Select</span> LocaleId <span style="color: blue;">From</span> Organization</pre>
<br /></div>
That will give you locale code of your organization. Now you need to convert this value to culture name (for example using this <a href="http://www.science.co.il/Language/Locale-codes.asp" target="_blank">post</a>) – in my case <span style="color: navy;">ru-RU</span>.<br />
<br />
<span style="color: black;">3. Execute following query against MSCRM_Config DB:</span><br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">Select</span> NVarCharColumn <span style="color: blue;">From</span> ServerSettingsProperties <span style="color: blue;">Where</span> ColumnName = <span style="color: #006080;">'AvailableBingMapLocales'</span></pre>
<br /></div>
That will give you the list of locales for which BingMaps would work (in my case it was <em><span style="color: navy;">cs-CZ;da-DK;nl-BE;nl-NL;en-AU;en-CA;en-IN;en-GB;en-US;fi-FI;fr-CA;fr-FR;de-DE;it-IT;ja-JP;nb-NO;pt-BR;pt-PT;es-MX;es-ES;es-US;sv-SE</span></em>).<br />
<br />
<span style="color: black;">4. Write and execute script to update list of locales using following template:</span><br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">Update</span> ServerSettingsProperties
<span style="color: blue;">Set</span> NVarCharColumn = <span style="color: #006080;">'Value from step 3;Value from step 2'</span>
<span style="color: blue;">Where</span> ColumnName = <span style="color: #006080;">'AvailableBingMapLocales'</span></pre>
<br /></div>
In my case:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">Update</span> ServerSettingsProperties
<span style="color: blue;">Set</span> NVarCharColumn = <span style="color: #006080;">'cs-CZ;da-DK;nl-BE;nl-NL;en-AU;en-CA;en-IN;en-GB;en-US;fi-FI;fr-CA;fr-FR;de-DE;it-IT;ja-JP;nb-NO;pt-BR;pt-PT;es-MX;es-ES;es-US;sv-SE;ru-RU'</span>
<span style="color: blue;">Where</span> ColumnName = <span style="color: #006080;">'AvailableBingMapLocales'</span></pre>
<br /></div>
5. Make iisreset and try to open form where bingmaps was not shown before. If you’ve done everything right map had to appear:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-mLngGEGizRM/UvhbLCV0zHI/AAAAAAAAB8U/19o0xKlWkoY/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-mLngGEGizRM/UvhbLCV0zHI/AAAAAAAAB8U/19o0xKlWkoY/s1600/2.png" height="215" width="320" /></a></div>
<br />
<br />
<span style="color: red; font-size: small;">PS This modifications are unsupported and mentioned changes can harm your deployment. Use it own risk.</span>Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-69020672570116014082014-01-22T00:41:00.003+02:002014-01-22T00:41:32.956+02:00MS CRM 2013: How to fix ‘sdkmessage With Id = {} Does Not Exist’ errorThis error appears when you are trying to import solution that contains plugin(-s) that handle Action(-s) from one environment to other environment:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-dPAW7bew1A0/Ut73SI3zerI/AAAAAAAAB70/1OHGygE48v0/s1600/0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-dPAW7bew1A0/Ut73SI3zerI/AAAAAAAAB70/1OHGygE48v0/s1600/0.png" height="46" width="320" /></a></div>
<br />
In Log file and trace file you can find description of error similar to following:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">sdkmessage With Id = a79cef5c-dd82-e311-a344-0800272ad985 Does Not Exist</pre>
<br /></div>
Source of issue is that Ids of SdkMessage<br />
<br />
This issue is well-known, <a href="https://connect.microsoft.com/dynamicssuggestions/feedback/details/810477/crm-2013-solution-import-fails-when-plugins-attached-to-custom-action-processes-sdkmessage-are-included-in-solution" target="_blank">registered on Connect</a> but haven’t been fixed yet.<br />
<br />
This article describes workaround that will allow to import such solution.<br />
<a name='more'></a><br />
1. Create on source system 2 solutions – first (let’s call it Solution 1) will contain Action(-s), second (let’s call it Solution 2) – plugin(-s) that handle Action(-s) from first solution.<br />
<br />
2. Export Solution 1 from source system and import it to target system.<br />
<br />
3. Get sdkmessageid for Action(-s) you have imported to target system using following scripts against target CRM DB:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">Select</span> SdkMessageId <span style="color: blue;">From</span> SdkMessage <span style="color: blue;">Where</span> Name = <span style="color: #006080;">'Your Action Name'</span>--<span style="color: blue;">Like</span> custom_Action</pre>
<br /></div>
In case you work with CRM Online or you don’t have an access to DB of CRM you can get it using .Net code like:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">QueryByAttribute query = <span style="color: blue;">new</span> QueryByAttribute(<span style="color: #006080;">"sdkmessage"</span>)
{
ColumnSet = <span style="color: blue;">new</span> ColumnSet(<span style="color: blue;">false</span>)
};
query.AddAttributeValue(<span style="color: #006080;">"name"</span>, <span style="color: #006080;">"Your Action Name"</span>);
Entity sdkmessage = service.RetrieveMultiple(query).Entities.FirstOrDefault();
Guid sdkmessageid = sdkmessage.Id;</pre>
<br /></div>
4. Export Solution 2 from source system and save it to your PC.<br />
<br />
5. Extract all files from Solution 2 and open customizations.xml with notepad or other text editor.<br />
<br />
6. Scroll through file, find section that is responsible for registration of steps (SdkMessageProcessingSteps). For each of steps change value inside SdkMessageId node with value that we’ve got on step 3:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-oOjF44jQeSA/Ut73gPyDgQI/AAAAAAAAB78/rVQccH-5t-I/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-oOjF44jQeSA/Ut73gPyDgQI/AAAAAAAAB78/rVQccH-5t-I/s1600/1.png" height="77" width="320" /></a></div>
<br />
7. Save customizations.xml and put it back to Solution 2 archive.<br />
<br />
8. Import Solution 2 to target system. Everything should work fine.Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-54185890158867023812014-01-19T22:36:00.001+02:002014-01-19T22:38:45.290+02:00MS CRM 2013: Issues uploading report to CRM OnlineToday I faced with really weird issue with Report developed for CRM Online. Report worked fine both at BIDS and my test On-Premise instance but once I’ve tried to upload it to productive instance I have got following error:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-IUYDWuSG1ls/Utw3qjjN24I/AAAAAAAAB7o/hFvHaLWKy4A/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-IUYDWuSG1ls/Utw3qjjN24I/AAAAAAAAB7o/hFvHaLWKy4A/s1600/1.png" height="253" width="320" /></a></div>
<br />
I’ve downloaded description file but error log didn’t contain any helpful information:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]:
An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.Detail:
<span style="color: blue;"><</span><span style="color: maroon;">OrganizationServiceFault</span> <span style="color: red;">xmlns:i</span><span style="color: blue;">="http://www.w3.org/2001/XMLSchema-instance"</span> <span style="color: red;">xmlns</span><span style="color: blue;">="http://schemas.microsoft.com/xrm/2011/Contracts"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">ErrorCode</span><span style="color: blue;">></span>-2147188072<span style="color: blue;"></</span><span style="color: maroon;">ErrorCode</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">ErrorDetails</span> <span style="color: red;">xmlns:d2p1</span><span style="color: blue;">="http://schemas.datacontract.org/2004/07/System.Collections.Generic"</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">Message</span><span style="color: blue;">></span>An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again.
If this problem persists, contact your system administrator.<span style="color: blue;"></</span><span style="color: maroon;">Message</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">Timestamp</span><span style="color: blue;">></span>2014-01-19T20:15:50.4036673Z<span style="color: blue;"></</span><span style="color: maroon;">Timestamp</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">InnerFault</span> <span style="color: red;">i:nil</span><span style="color: blue;">="true"</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">TraceText</span> <span style="color: red;">i:nil</span><span style="color: blue;">="true"</span> <span style="color: blue;">/></span>
<span style="color: blue;"></</span><span style="color: maroon;">OrganizationServiceFault</span><span style="color: blue;">></span></pre>
<br /></div>
After that I’ve opened SDK for CRM and found <a href="http://msdn.microsoft.com/en-us/library/hh547428.aspx" target="_blank">this article</a> that describes limitations of reports in CRM Online. I went through all used formulas and replaced parts that used <span style="color: red;">Equals</span> and <span style="color: red;">Decimal.Zero</span>.<br />
<br />
So my suggestion in case you have problems uploading report to CRM Online:<br />
<br />
1. Recheck that your report uses <a href="http://msdn.microsoft.com/en-us/library/gg328302%28v=crm.6%29.aspx#FetchBased" target="_blank">Fetch Xml DataSource</a>.<br />
2. Recheck all formulas that you have in your report and remove (or replace) <a href="http://msdn.microsoft.com/en-us/library/hh547428.aspx#BKMK_Allowed" target="_blank">all denied types and denied members</a>.<br />
3. Ensure that your report doesn’t use <a href="http://technet.microsoft.com/en-us/library/ms153561.aspx" target="_blank">references</a> to any assemblies.Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-46977523234763025682014-01-12T21:02:00.001+02:002014-01-12T21:03:50.518+02:00MS CRM 2011/2013: Open new email form with To and Regarding fields prefilledAbout a year ago I wrote <a href="http://a33ik.blogspot.com/2013/01/open-new-activity-form-with-regarding.html" target="_blank">small article</a> how to open new activity form with Regarding field prefilled.<br />
This week I had a similar task but this time I had to write a JavaScript that will open email form with To field prefilled. So here is the script that you can use:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">function</span> OpenEmail(recordid, recordtypecode) {
<span style="color: blue;">var</span> <span style="color: blue;">params</span> = <span style="color: #006080;">"pId="</span> + recordid + <span style="color: #006080;">"&pName=&pType="</span> + recordtypecode;
<span style="color: blue;">params</span> += <span style="color: #006080;">"&partyid="</span> + recordid + <span style="color: #006080;">"&partyname=&partytype="</span> + recordtypecode;
<span style="color: blue;">var</span> url = <span style="color: #006080;">"/main.aspx?etc=4202&pagetype=entityrecord&extraqs="</span> + encodeURIComponent(<span style="color: blue;">params</span>);
url = Xrm.Page.context.prependOrgName(url);
window.open(url);
}</pre>
<br /></div>
Here is sample of usage:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">OpenEmail(<span style="color: #006080;">"c8576fa9-155e-e311-bbc5-6c3be5a8d218"</span>, 2);</pre>
<br /></div>
This small JavaScript will open new email form with Regarding and To fields prefilled with contact with Id that equals to "c8576fa9-155e-e311-bbc5-6c3be5a8d218".Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-56953718719610549652014-01-09T01:39:00.001+02:002014-01-09T01:39:50.683+02:00Microsoft CRM 2011/2013: Colorizing Service CalendarThis is how standard service calendar looks like:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-tfGFlLNOBmI/Us3g5tXGVwI/AAAAAAAAB7A/an7-_ZkxKrE/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-tfGFlLNOBmI/Us3g5tXGVwI/AAAAAAAAB7A/an7-_ZkxKrE/s1600/1.png" height="132" width="320" /></a></div>
<br />
Today I was asked with customer is it possible to change colorizing schema of Service Calendar. I started to look for information about it and found following article - <a href="http://msdn.microsoft.com/en-us/library/gg309501.aspx" title="http://msdn.microsoft.com/en-us/library/gg309501.aspx">http://msdn.microsoft.com/en-us/library/gg309501.aspx</a><br />
Unfortunately I was not able to understand now to make it from first attempt and I contacted Microsoft to get some clarification and help. I’m really appreciated to <a href="http://blogs.msdn.com/b/crm/archive/2006/11/17/bio-jim-daly.aspx" target="_blank">Jim Daly</a> who got in touch with me and gave some explanations regarding SDK article. I will share with results I've got in this article.<br />
<a name='more'></a>Follow the steps to change appearance of Service Calendar:<br />
<br />
1. Create a css webresource with Display Name AppointmentBookConfig and put following CSS inside:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-QHBKYy9E5To/Us3hYzEiH0I/AAAAAAAAB7Q/uhhj8rGQYN8/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-QHBKYy9E5To/Us3hYzEiH0I/AAAAAAAAB7Q/uhhj8rGQYN8/s1600/3.png" height="209" width="320" /></a></div>
<br />
<span style="color: red;">Note: Display Name of webresource has to be AppointmentBookConfig!!!</span><br />
<div>
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus1</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #FF0000;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#FF0000',endColorstr='#FF0000');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #FF0000 0%, #FF0000 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #FF0000 0%,#FF0000 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #FF0000 0%,#FF0000 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #FF0000 0%,#FF0000 100%);
}
<span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus2</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #00FF00;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#00FF00',endColorstr='#00FF00');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #00FF00 0%, #00FF00 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #00FF00 0%,#00FF00 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #00FF00 0%,#00FF00 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #00FF00 0%,#00FF00 100%);
}
<span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus3</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #0000FF;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#0000FF',endColorstr='#0000FF');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #0000FF 0%, #0000FF 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #0000FF 0%,#0000FF 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #0000FF 0%,#0000FF 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #0000FF 0%,#0000FF 100%);
}
<span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus4</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #FFFF00;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#FFFF00',endColorstr='#FFFF00');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #FFFF00 0%, #FFFF00 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #FFFF00 0%,#FFFF00 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #FFFF00 0%,#FFFF00 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #FFFF00 0%,#FFFF00 100%);
}
<span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus6</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #FF00FF;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#FF00FF',endColorstr='#FF00FF');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #FF00FF 0%, #FF00FF 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #FF00FF 0%,#FF00FF 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #FF00FF 0%,#FF00FF 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #FF00FF 0%,#FF00FF 100%);
}
<span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus7</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #00FFFF;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#00FFFF',endColorstr='#00FFFF');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #00FFFF 0%, #00FFFF 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #00FFFF 0%,#00FFFF 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #00FFFF 0%,#00FFFF 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #00FFFF 0%,#00FFFF 100%);
}
<span style="color: blue;">div</span><span style="color: #cc6633;">.ganttBlockserviceappointmentStatus8</span>
{
<span style="color: blue;">border</span>: <span style="color: #006080;">1px solid #7F7F7F;</span>
FILTER: progid:DXImageTransform<span style="color: #cc6633;">.Microsoft</span><span style="color: #cc6633;">.gradient</span>(GradientType=0,startColorstr='#7F7F7F',endColorstr='#7F7F7F');
<span style="color: blue;">background</span>: -moz-linear-gradient(<span style="color: blue;">top</span>, #7F7F7F 0%, #7F7F7F 100%);
<span style="color: blue;">background</span>: -webkit-linear-gradient(<span style="color: blue;">top</span>, #7F7F7F 0%,#7F7F7F 100%);
<span style="color: blue;">background</span>: -ms-linear-gradient(<span style="color: blue;">top</span>, #7F7F7F 0%,#7F7F7F 100%);
<span style="color: blue;">background</span>: linear-gradient(<span style="color: blue;">top</span>, #7F7F7F 0%,#7F7F7F 100%);
} </pre>
</div>
<br />
<div>
<span style="color: red;">Note: div classes since UR 12 CRM 2011 are case sensitive so be attentive!!!</span></div>
<br />
<div>
2. Save and publish this webresource.</div>
<br />
3. Reload Service calendar and check that changes were applied in accordance to your webresource:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-ZeL-JrMxV1E/Us3hoznbrGI/AAAAAAAAB7Y/vVMIYO3Y7tU/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-ZeL-JrMxV1E/Us3hoznbrGI/AAAAAAAAB7Y/vVMIYO3Y7tU/s1600/2.png" height="131" width="320" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-134049454020452862014-01-03T21:05:00.001+02:002014-01-03T21:05:47.044+02:00MVP Renewed – 4<p>Fifth year in a row I have got MVP award. Congratulations to all MVP's who has got award first time or was re-awarded.</p> Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-14828335398185360162013-11-04T01:25:00.000+02:002013-11-04T01:25:54.702+02:00Microsoft CRM 2013 - Integration with BingMaps: difference between OnPremise and Online instancesDifference I faced today is following – OnPremise instance has Bing Map api key field in System Settings but Online doesn’t.<br />
<br />
OnPremise:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-5mNjCEbjqvM/UnbbDrC4GgI/AAAAAAAAB6o/4zSpVysXkz8/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="66" src="http://1.bp.blogspot.com/-5mNjCEbjqvM/UnbbDrC4GgI/AAAAAAAAB6o/4zSpVysXkz8/s320/2.png" width="320" /></a></div>
OnLine:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-tORVDkuhjTo/UnbbHXXH2uI/AAAAAAAAB6w/hUy0ZdRjGQg/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="54" src="http://1.bp.blogspot.com/-tORVDkuhjTo/UnbbHXXH2uI/AAAAAAAAB6w/hUy0ZdRjGQg/s320/1.png" width="320" /></a></div>
<br />
<a name='more'></a>In case you build solutions that uses BingMapKey in other way then OOB BingMap control and make solution works the same way both OnPremise and Online you can manually update this field through code:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">QueryExpression query = <span style="color: blue;">new</span> QueryExpression(<span style="color: #006080;">"organization"</span>)
{
ColumnSet = <span style="color: blue;">new</span> ColumnSet(<span style="color: blue;">false</span>)
};
Entity organization = service.RetrieveMultiple(query).Entities.FirstOrDefault();
organization[<span style="color: #006080;">"bingmapsapikey"</span>] = <span style="color: #006080;">"Your Bing Maps API Key"</span>;
service.Update(organization);</pre>
<br /></div>
In case you want to use your key somewhere in .Net code (plugins, custom workflow activities, external applications) you can use following code to get value of this key:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">string</span> bingmapkey = <span style="color: blue;">null</span>;
QueryExpression organizationQuery = <span style="color: blue;">new</span> QueryExpression(<span style="color: #006080;">"organization"</span>)
{
ColumnSet = <span style="color: blue;">new</span> ColumnSet(<span style="color: #006080;">"bingmapsapikey"</span>)
};
Entity organization = service.RetrieveMultiple(organizationQuery).Entities.FirstOrDefault();
<span style="color: blue;">if</span> (organization != <span style="color: blue;">null</span> && organization.Contains(<span style="color: #006080;">"bingmapsapikey"</span>))
{
bingmapkey = organization.GetAttributeValue<<span style="color: blue;">string</span>>(<span style="color: #006080;">"bingmapsapikey"</span>);
}
<span style="color: green;">//Usage of bingmap api key</span></pre>
<br /></div>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-54621251329474189222013-10-31T04:05:00.001+02:002013-10-31T04:05:20.753+02:00Microsoft CRM 2013: Adding standard Bing Map control to forms of custom entitiesIn CRM 2013 Microsoft released really great feature – OOB integration with BingMaps. Unfortunately list of entities that support BingMaps control is limited to Account, Contact, Lead, Quote, Order, Invoice, Competitor and System User.<br />
I did small investigation how this control is organized and I can confirm that it is possible to add OOB Bing Maps control to forms of custom entities. But be careful - provided solution is 100% unsupported but doesn’t require any knowledge of development, JavaScript, HTML and so on.<br />
<a name='more'></a>1. Create field for your entity that will be used for storing of address (in my case I’ve created custom field slick_address).<br />
2. Put it on the form:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-5cL-dPX4EEk/UnG6e9RmKtI/AAAAAAAAB6A/gKos0uR7l38/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="252" src="http://3.bp.blogspot.com/-5cL-dPX4EEk/UnG6e9RmKtI/AAAAAAAAB6A/gKos0uR7l38/s320/1.png" width="320" /></a></div>
<br />
3. Save and publish form and entity.<br />
4. Create solution and add your custom entity inside.<br />
5. Export and unzip solution.<br />
6. Open customizations.xml file and find attribute you’ve added:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-rG5AJ2_v0rc/UnG6k7B27TI/AAAAAAAAB6I/RBzBmtv91Ck/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="102" src="http://4.bp.blogspot.com/-rG5AJ2_v0rc/UnG6k7B27TI/AAAAAAAAB6I/RBzBmtv91Ck/s320/2.png" width="320" /></a></div>
<br />
7. Add following Xml after address field (put field name you use for address into AddressField node):<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><row>
<cell id=<span style="color: #006080;">"{7c550a71-c8f5-469b-a221-aa4563525b70}"</span> showlabel=<span style="color: #006080;">"false"</span> rowspan=<span style="color: #006080;">"8"</span> colspan=<span style="color: #006080;">"1"</span> auto=<span style="color: #006080;">"false"</span>>
<labels>
<label description=<span style="color: #006080;">"Bing Maps"</span> languagecode=<span style="color: #006080;">"1033"</span> />
</labels>
<control id=<span style="color: #006080;">"mapcontrol"</span> classid=<span style="color: #006080;">"{62B0DF79-0464-470F-8AF7-4483CFEA0C7D}"</span>>
<parameters>
<AddressField>slick_address</AddressField>
</parameters>
</control>
</cell>
</row></pre>
<br /></div>
After this your Xml should look like following:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-HYTagHY_J_o/UnG6rCKmEfI/AAAAAAAAB6Q/km6pOP066fg/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="99" src="http://2.bp.blogspot.com/-HYTagHY_J_o/UnG6rCKmEfI/AAAAAAAAB6Q/km6pOP066fg/s320/3.png" width="320" /></a></div>
<br />
8. Save Xml and pack it back to archive with solution.<br />
9. Import Solution into CRM and publish changes.<br />
10 Once you’ve done this - open your entity form, enter address into your address field and check that address is displayed in BingMaps control:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-Af5oz-qK4r8/UnG6xVI5lII/AAAAAAAAB6Y/cEb_9sAzuAY/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="123" src="http://4.bp.blogspot.com/-Af5oz-qK4r8/UnG6xVI5lII/AAAAAAAAB6Y/cEb_9sAzuAY/s320/4.png" width="320" /></a></div>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-4956303279067426312013-10-31T00:45:00.002+02:002013-10-31T00:46:18.194+02:00Actions: usage of input/output arguments in plugins that handle Actions<span style="font-size: small;">Main message is that input/output arguments are available in InputParameters/OutputParameters collections of PluginExecutionContext.</span><br />
<br />
<b><span style="font-size: small;">Usage of Input argument</span></b><br />
<span style="font-size: small;">Following code shows how to check that Input Argument was passed and get value:</span><br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">if</span> (localContext.PluginExecutionContext.InputParameters.Contains(<span style="color: #006080;">"ArgumentName"</span>))
{
<span style="color: blue;">string</span> stringInputArgument = (<span style="color: blue;">string</span>)localContext.PluginExecutionContext.InputParameters[<span style="color: #006080;">"ArgumentName"</span>];
}
<span style="color: blue;">else</span>
{
<span style="color: green;">//Your code for case when Argument was not passed</span>
}</pre>
<br /></div>
<b><span style="font-size: small;">Usage of Output argument</span></b><br />
<span style="font-size: small;">Following code shows how to set Output argument:</span><br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">localContext.PluginExecutionContext.OutputParameters[<span style="color: #006080;">"OutputArgumentName"</span>] = <Value>;</pre>
<br />
<span style="font-size: small;">One thing you should remember is that step that handles your action and sets Output arguments had to be registered on Post Operation (40).</span></div>
<br />
<span style="font-size: small;">For those who use CRM Developer Toolkit – registration of new plugin, registration of your step in code of your plugin and part of RegisterFile.crmregister file:</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-D6PS13aXhbc/UnGL0KZRCdI/AAAAAAAAB5o/hoiQHnkipns/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="221" src="http://3.bp.blogspot.com/-D6PS13aXhbc/UnGL0KZRCdI/AAAAAAAAB5o/hoiQHnkipns/s320/2.png" width="320" /></a></div>
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">base</span>.RegisteredEvents.Add(<span style="color: blue;">new</span> Tuple<<span style="color: blue;">int</span>, <span style="color: blue;">string</span>, <span style="color: blue;">string</span>, Action<LocalPluginContext>>(<span style="color: red; font-size: small;"><b>40</b></span>,
<span style="color: #006080;">"MessageName"</span>, <span style="color: blue;">null</span>, <span style="color: blue;">new</span> Action<LocalPluginContext>(PluginClass)));</pre>
</div>
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><Step CustomConfiguration=<span style="color: #006080;">""</span> Name=<span style="color: #006080;">"StepName"</span> Description=<span style="color: #006080;">"Description"</span> Id=<span style="color: #006080;">"024c3b93-6041-e311-ad38-6c3be5a8d218"</span>
MessageName=<span style="color: #006080;">"MessageName"</span> Mode=<span style="color: #006080;">"Synchronous"</span> PrimaryEntityName=<span style="color: #006080;">"none"</span> Rank=<span style="color: #006080;">"1"</span> SecureConfiguration=<span style="color: #006080;">""</span>
Stage=<span style="color: #006080;">"<b><span style="color: red; font-size: x-small;">PostOutsideTransaction</span></b>"</span> SupportedDeployment=<span style="color: #006080;">"ServerOnly"</span>></pre>
<br />
<span style="font-size: small;">For those who use PluginRegistration tool:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-q0hbajpn_oQ/UnGL8HWh4XI/AAAAAAAAB5w/rSIGNe_sxBw/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="http://4.bp.blogspot.com/-q0hbajpn_oQ/UnGL8HWh4XI/AAAAAAAAB5w/rSIGNe_sxBw/s320/1.png" width="320" /></a></div>
<span style="font-size: small;"></span><br />
<span style="font-size: x-small;"></span> Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-66004852463688647322013-10-28T10:37:00.000+02:002013-10-28T10:37:26.781+02:00Actions, input parameters and “Object reference not set to an instance of an object” exceptionDuring playing with Actions I wrote simple .Net code that invoked execution of an Action:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">slick_CustomActionsTestRequest request = <span style="color: blue;">new</span> slick_CustomActionsTestRequest()
{
BoolInArgument = <span style="color: blue;">true</span>,
DateTimeInArgument = DateTime.Now,
DecimalInArgument = <span style="color: blue;">decimal</span>.Zero
};
slick_CustomActionsTestResponse response = service.Execute(request) <span style="color: blue;">as</span> slick_CustomActionsTestResponse;</pre>
<br />
During testing I have got really weird and unclear error – “Object reference not set to an instance of an object.”:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-qVFqIqjDqUU/Um4h-Xgwy6I/AAAAAAAAB40/DHLb_qZ7pQc/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="106" src="http://4.bp.blogspot.com/-qVFqIqjDqUU/Um4h-Xgwy6I/AAAAAAAAB40/DHLb_qZ7pQc/s320/1.png" width="320" /></a></div>
</div>
<a name='more'></a><br />
After some investigation I understood that in case you have declared input parameters of Entity, EntityReference, EntityCollection, Money, Picklist or string type (<b>even not marked as required!</b>) to make code work without exception you need to pass this parameters:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-8aOkXexrWhM/Um4iGLUdEsI/AAAAAAAAB48/y9qINLwfFNQ/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="210" src="http://2.bp.blogspot.com/-8aOkXexrWhM/Um4iGLUdEsI/AAAAAAAAB48/y9qINLwfFNQ/s320/2.png" width="320" /></a></div>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-23200745997709193182013-10-27T22:17:00.000+02:002013-10-27T22:20:23.555+02:00CRM Developer Toolkit for Microsoft Dynamics CRM 2013 - Visual Studio 2012 CrashingAfter CRM 2013 was released I decided to install CRM Develoepr toolkit for CRM 2013 on my workstation. After I tried to create CRM Package solution I have got following error and VS crashed and restarted:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-oc_KhAPKTNE/Um10Pl7enDI/AAAAAAAAB4c/vW-OUkaNg2E/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="http://1.bp.blogspot.com/-oc_KhAPKTNE/Um10Pl7enDI/AAAAAAAAB4c/vW-OUkaNg2E/s320/1.png" width="320" /></a></div>
<br />
<a name='more'></a>In event viewer I found following error:<br />
<div>
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">Faulting application name: devenv.exe, version: 11.0.60315.1, time stamp: 0x5142bb7b
Faulting module name: msenv.dll, version: 11.0.60315.1, time stamp: 0x5142bb91
Exception code: 0xc0000005
Fault offset: 0x0009467d
Faulting process id: 0x1804
Faulting application start time: 0x01ced347fa656660
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
Faulting module path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\msenv.dll
Report Id: 7faf6b4b-3f3b-11e3-a4eb-e1498e4f5d0e</pre>
</div>
<br />
<div>
This description hasn’t helped me to find the source of an error and fix it so I started to look for a solution <span class="short_text" id="result_box" lang="en"><span class="hps">on the Internet</span></span> and found following article written by Jason Lattimer - <a href="http://jlattimer.blogspot.com/2013/02/crm-developer-toolkit-visual-studio.html" title="http://jlattimer.blogspot.com/2013/02/crm-developer-toolkit-visual-studio.html">http://jlattimer.blogspot.com/2013/02/crm-developer-toolkit-visual-studio.html</a></div>
<br />
So it seems that the reason for crash was some extension for VS. The only extension I have installed was .Net Reflector Visual Studio Extension 8.0:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-IT-0HMijIGw/Um10hsKu7bI/AAAAAAAAB4k/XDr6v6e91AA/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="19" src="http://1.bp.blogspot.com/-IT-0HMijIGw/Um10hsKu7bI/AAAAAAAAB4k/XDr6v6e91AA/s320/2.png" width="320" /></a></div>
So I opened “Programs and Features” menu, uninstalled extension and crashing stopped. I hope this trick will help someone.Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-47757318989927175182013-10-27T03:58:00.001+03:002013-10-28T17:04:11.468+02:00Microsoft Dynamics CRM 2013: Actions: deployment of plugins through CRM Developer ToolkitI played with new version of CRM Developer Toolkit and was not able to find a way to register plugin that handles action using UI. Following post describes workaround how make it possible.<br />
<a name='more'></a>1. Create Solution and add CRM Plugin project inside:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-9Kb6TNX6gNs/UmxGxP6PKRI/AAAAAAAAB3c/d_so8YX_ieI/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-9Kb6TNX6gNs/UmxGxP6PKRI/AAAAAAAAB3c/d_so8YX_ieI/s1600/1.png" /></a></div>
<br />
2. Create new plugin and register it to handle some available action (I used creation of account in post mode):<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-xICb4MbW7Bg/UmxG02BUI2I/AAAAAAAAB3k/7MF_UQGTyMw/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="217" src="http://1.bp.blogspot.com/-xICb4MbW7Bg/UmxG02BUI2I/AAAAAAAAB3k/7MF_UQGTyMw/s320/2.png" width="320" /></a></div>
<br />
3. Open class of your plugin and fix line<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">base</span>.RegisteredEvents.Add(<span style="color: blue;">new</span> Tuple<<span style="color: blue;">int</span>, <span style="color: blue;">string</span>, <span style="color: blue;">string</span>, Action<LocalPluginContext>>(40, <span style="color: #006080;">"Create"</span>, <span style="color: #006080;">"account"</span>, <span style="color: blue;">new</span> Action<LocalPluginContext>(ExecuteHandleCustomAction)));</pre>
<br /></div>
to line<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">base</span>.RegisteredEvents.Add(<span style="color: blue;">new</span> Tuple<<span style="color: blue;">int</span>, <span style="color: blue;">string</span>, <span style="color: blue;">string</span>, Action<LocalPluginContext>>(40, <span style="color: #006080;">"slick_CustomActionsTest"</span>, <span style="color: blue;">null</span>, <span style="color: blue;">new</span> Action<LocalPluginContext>(ExecuteHandleCustomAction)));</pre>
<br /></div>
4. Open RegisterFile.crmregister file that is located in your Dynamics CRM 2013 Package project, find line that describes step of your plugin and fix<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;"><</span><span style="color: maroon;">Step</span> <span style="color: red;">CustomConfiguration</span><span style="color: blue;">=""</span> <span style="color: red;">Name</span><span style="color: blue;">="HandleCustomAction"</span> <span style="color: red;">Description</span><span style="color: blue;">="Handles Custom Action"</span> <span style="color: red;">Id</span><span style="color: blue;">="00000000-0000-0000-0000-000000000000"</span>
<span style="color: red;">MessageName</span><span style="color: blue;">="Create"</span> <span style="color: red;">Mode</span><span style="color: blue;">="Synchronous"</span> <span style="color: red;">PrimaryEntityName</span><span style="color: blue;">="account"</span> <span style="color: red;">Rank</span><span style="color: blue;">="1"</span> <span style="color: red;">SecureConfiguration</span><span style="color: blue;">=""</span>
<span style="color: red;">Stage</span><span style="color: blue;">="PostOutsideTransaction"</span> <span style="color: red;">SupportedDeployment</span><span style="color: blue;">="ServerOnly"</span><span style="color: blue;">></span></pre>
<br /></div>
to line<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;"><</span><span style="color: maroon;">Step</span> <span style="color: red;">CustomConfiguration</span><span style="color: blue;">=""</span> <span style="color: red;">Name</span><span style="color: blue;">="HandleCustomAction"</span> <span style="color: red;">Description</span><span style="color: blue;">="Handles Custom Action"</span> <span style="color: red;">Id</span><span style="color: blue;">="00000000-0000-0000-0000-000000000000"</span>
<span style="color: red;">MessageName</span><span style="color: blue;">="slick_CustomActionsTest"</span> <span style="color: red;">Mode</span><span style="color: blue;">="Synchronous"</span> <span style="color: red;">PrimaryEntityName</span><span style="color: blue;">="none"</span> <span style="color: red;">Rank</span><span style="color: blue;">="1"</span> <span style="color: red;">SecureConfiguration</span><span style="color: blue;">=""</span>
<span style="color: red;">Stage</span><span style="color: blue;">="PostOutsideTransaction"</span> <span style="color: red;">SupportedDeployment</span><span style="color: blue;">="ServerOnly"</span><span style="color: blue;">></span></pre>
<br /></div>
5. Save files and try to deploy your solution to CRM server. In case you’ve done all steps properly you would not get errors during deployment. In case you want to ensure that plugin was deployed properly open Plugin Registration Tool:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-T7lmjLRkiNA/UmxG5POHNTI/AAAAAAAAB3s/Ol5eWNquG-U/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="222" src="http://1.bp.blogspot.com/-T7lmjLRkiNA/UmxG5POHNTI/AAAAAAAAB3s/Ol5eWNquG-U/s320/3.png" width="320" /></a></div>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0tag:blogger.com,1999:blog-7233186359690994418.post-4961613192070647482013-10-27T03:55:00.004+03:002013-10-28T10:38:00.603+02:00Microsoft Dynamics CRM 2013: Actions walkthrough for .Net and JavaScript developersI believe that almost every developer for Dynamics CRM faced with scenario when he/she had to invoke some complex logic on a server side, pass parameters and receive a response back. Before CRM 2013 we used workarounds similar to <a href="http://code.msdn.microsoft.com/windowsdesktop/Trigger-a-Plug-in-in-75699228" target="_blank">this one</a>. Once Dynamics CRM 2013 was released we have got solution that would not require ‘magic’.<br />
<a name='more'></a><div id="extendedEntryBreak" name="extendedEntryBreak">
</div>
Following posts describe how to create Actions in CRM side:<br />
<a href="http://garethtuckercrm.com/2013/10/15/crm-2013-new-features-actions/" title="http://garethtuckercrm.com/2013/10/15/crm-2013-new-features-actions/">http://garethtuckercrm.com/2013/10/15/crm-2013-new-features-actions/</a><br />
<a href="http://inogic.blogspot.com/2013/09/introduction-to-actions-in-crm-2013.html" title="http://inogic.blogspot.com/2013/09/introduction-to-actions-in-crm-2013.html">http://inogic.blogspot.com/2013/09/introduction-to-actions-in-crm-2013.html</a><br />
This is how my Custom Action look like:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-o_Wb_jseYuc/Umxj5cT_oiI/AAAAAAAAB38/5J7VcH-JGHA/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="147" src="http://4.bp.blogspot.com/-o_Wb_jseYuc/Umxj5cT_oiI/AAAAAAAAB38/5J7VcH-JGHA/s320/1.png" width="320" /></a></div>
<b><span style="font-size: medium;">Usage of Custom Actions in .Net:</span></b><br />
1. Actions are available for Early binding. To get Early Binding classes you need to run CrmSvcUtil (you can find this utile in SDK package, bin folder) using following command line:<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">CrmSvcUtil.exe /url:http://crm:5555/contoso/XRMServices/2011/Organization.svc /out:Classes.cs /namespace:CustomActions /serviceContextName:CrmServiceContext /generateActions</pre>
<br /></div>
My command sample can be used for OnPremise deployments. Detailed information regarding generating of Early Binding classes for all types of deployments you can find in <a href="http://msdn.microsoft.com/en-us/library/gg695820.aspx" target="_blank">this article</a>.<br />
<br />
Add generated Classes.cs to your project and start using it:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/--yC_HAUZ-QE/UmxkF5vwoFI/AAAAAAAAB4E/6KVm8GQ1THc/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="http://3.bp.blogspot.com/--yC_HAUZ-QE/UmxkF5vwoFI/AAAAAAAAB4E/6KVm8GQ1THc/s320/2.png" width="320" /></a></div>
<br />
Sample of code that instantiates request, executes it and receives result:<br />
<br />
<div>
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">slick_CustomActionsTestRequest request = <span style="color: blue;">new</span> slick_CustomActionsTestRequest()
{
BoolInArgument = <span style="color: blue;">true</span>,
DateTimeInArgument = DateTime.Now,
DecimalInArgument = <span style="color: blue;">decimal</span>.Zero
};
slick_CustomActionsTestResponse response = service.Execute(request) <span style="color: blue;">as</span> slick_CustomActionsTestResponse;
<span style="color: green;">//Processing of response</span></pre>
</div>
<br />
<div>
2. If you don’t like or don’t want to use Early binding you case use OrganizationRequest/OrganizationResponse. Sample of code:</div>
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">OrganizationRequest request = <span style="color: blue;">new</span> OrganizationRequest(<span style="color: #006080;">"slick_CustomActionsTest"</span>);
request[<span style="color: #006080;">"BoolInArgument"</span>] = <span style="color: blue;">true</span>;
request[<span style="color: #006080;">"DateTimeInArgument"</span>] = DateTime.Now;
request[<span style="color: #006080;">"DecimalInArgument"</span>] = <span style="color: blue;">decimal</span>.Zero;
OrganizationResponse response = service.Execute(request);
<span style="color: blue;">bool</span> boolvalue = (<span style="color: blue;">bool</span>)response.Results[<span style="color: #006080;">"BoolOutArgument"</span>];</pre>
<br /></div>
<br />
<div>
<b><span style="font-size: medium;">Usage of Actions in JavaScript:</span></b></div>
<br />
1. Prepare Soap Xml request. The easiest way to do it is to use SoapLogger application that is the part of SDK package. Detailed information you can find <a href="http://msdn.microsoft.com/en-us/library/gg594434.aspx#BKMK_CaptureHTTPTraffic" target="_blank">here</a>. Sample of code that captures request and response follows:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;">using</span> (StreamWriter output = <span style="color: blue;">new</span> StreamWriter(<span style="color: #006080;">"output.txt"</span>))
{
SoapLoggerOrganizationService slos = <span style="color: blue;">new</span> SoapLoggerOrganizationService(serverConfig.OrganizationUri, service, output);
OrganizationRequest r = <span style="color: blue;">new</span> OrganizationRequest(<span style="color: #006080;">"slick_CustomActionsTest"</span>);
r[<span style="color: #006080;">"BoolInArgument"</span>] = <span style="color: blue;">true</span>;
r[<span style="color: #006080;">"DateTimeInArgument"</span>] = DateTime.Now;
r[<span style="color: #006080;">"DecimalInArgument"</span>] = <span style="color: blue;">decimal</span>.Zero;
r[<span style="color: #006080;">"EntityCollectionInArgument"</span>] = <span style="color: blue;">new</span> EntityCollection()
{
EntityName = <span style="color: #006080;">"account"</span>
};
r[<span style="color: #006080;">"EntityInArgument"</span>] = <span style="color: blue;">new</span> Entity(<span style="color: #006080;">"account"</span>);
r[<span style="color: #006080;">"EntityReferenceInArgument"</span>] = <span style="color: blue;">new</span> EntityReference(<span style="color: #006080;">"account"</span>, Guid.Empty);
r[<span style="color: #006080;">"FloatInArgument"</span>] = <span style="color: blue;">double</span>.Parse(<span style="color: #006080;">"0"</span>);
r[<span style="color: #006080;">"IntegerInArgument"</span>] = 0;
r[<span style="color: #006080;">"MoneyInArgument"</span>] = <span style="color: blue;">new</span> Money(<span style="color: blue;">decimal</span>.Zero);
r[<span style="color: #006080;">"PicklistInArgument"</span>] = <span style="color: blue;">new</span> OptionSetValue(1);
r[<span style="color: #006080;">"StringInArgument"</span>] = <span style="color: #006080;">""</span>;
slos.Execute(r);
}</pre>
<br /></div>
In output.txt file you can find following:<br />
<br />
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"><span style="color: blue;"><</span><span style="color: maroon;">s:Envelope</span> <span style="color: red;">xmlns:s</span><span style="color: blue;">='http://schemas.xmlsoap.org/soap/envelope/'</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">s:Body</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">Execute</span> <span style="color: red;">xmlns</span><span style="color: blue;">='http://schemas.microsoft.com/xrm/2011/Contracts/Services'</span>
<span style="color: red;">xmlns:i</span><span style="color: blue;">='http://www.w3.org/2001/XMLSchema-instance'</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">request</span> <span style="color: red;">i:type</span><span style="color: blue;">='b:slick_CustomActionsTestRequest'</span>
<span style="color: red;">xmlns:a</span><span style="color: blue;">='http://schemas.microsoft.com/xrm/2011/Contracts'</span>
<span style="color: red;">xmlns:b</span><span style="color: blue;">='http://schemas.microsoft.com/xrm/2011/slick/'</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">a:Parameters</span> <span style="color: red;">xmlns:c</span><span style="color: blue;">='http://schemas.datacontract.org/2004/07/System.Collections.Generic'</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">a:KeyValuePairOfstringanyType</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">c:key</span><span style="color: blue;">></span>BoolInArgument<span style="color: blue;"></</span><span style="color: maroon;">c:key</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">c:value</span> <span style="color: red;">i:type</span><span style="color: blue;">='d:boolean'</span> <span style="color: red;">xmlns:d</span><span style="color: blue;">='http://www.w3.org/2001/XMLSchema'</span><span style="color: blue;">></span>true<span style="color: blue;"></</span><span style="color: maroon;">c:value</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">a:KeyValuePairOfstringanyType</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">a:KeyValuePairOfstringanyType</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">c:key</span><span style="color: blue;">></span>DateTimeInArgument<span style="color: blue;"></</span><span style="color: maroon;">c:key</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">c:value</span> <span style="color: red;">i:type</span><span style="color: blue;">='d:dateTime'</span> <span style="color: red;">xmlns:d</span><span style="color: blue;">='http://www.w3.org/2001/XMLSchema'</span><span style="color: blue;">></span>2013-10-27T01:08:29.0439804+03:00<span style="color: blue;"></</span><span style="color: maroon;">c:value</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">a:KeyValuePairOfstringanyType</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">a:KeyValuePairOfstringanyType</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">c:key</span><span style="color: blue;">></span>DecimalInArgument<span style="color: blue;"></</span><span style="color: maroon;">c:key</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">c:value</span> <span style="color: red;">i:type</span><span style="color: blue;">='d:decimal'</span> <span style="color: red;">xmlns:d</span><span style="color: blue;">='http://www.w3.org/2001/XMLSchema'</span><span style="color: blue;">></span>0<span style="color: blue;"></</span><span style="color: maroon;">c:value</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">a:KeyValuePairOfstringanyType</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">a:Parameters</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">a:RequestId</span> <span style="color: red;">i:nil</span><span style="color: blue;">='true'</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">a:RequestName</span><span style="color: blue;">></span>slick_CustomActionsTest<span style="color: blue;"></</span><span style="color: maroon;">a:RequestName</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">request</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">Execute</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">s:Body</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">s:Envelope</span><span style="color: blue;">></span></pre>
<br /></div>
<br />
this is the Soap Xml request you will use.<br />
<br />
2. Use this Soap request with CustomAcionExecutor.js library I’ve developed. Sample of usage:<br />
<br />
<div>
<pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;">CustomActionExecutor.Execute(
{
requestXml: requestXml,
async: <span style="color: blue;">true</span>,
successCallback: <span style="color: blue;">function</span>(result){
},
errorCallback: <span style="color: blue;">function</span> (e) {
}
});</pre>
</div>
<br />
<div>
In result you will get parsed response from server:</div>
<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-74iGF3DYClg/UmxkWMoLNXI/AAAAAAAAB4M/r01zUQN91W4/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-74iGF3DYClg/UmxkWMoLNXI/AAAAAAAAB4M/r01zUQN91W4/s320/3.png" width="280" /></a></div>
</div>
<br />
<div>
Source code of CustomActionExecutor.js:</div>
<br />
<iframe frameborder="0" height="120" scrolling="no" src="https://skydrive.live.com/embed?cid=F63E4BCD4A7F64A4&resid=F63E4BCD4A7F64A4%21364&authkey=AAKArqPwdpYYGxs" width="98"></iframe>
Anonymoushttp://www.blogger.com/profile/03225186683208658482noreply@blogger.com0