tag:blogger.com,1999:blog-69478675240496457292024-03-13T20:02:38.732+02:00Crm Dynamics Blogscrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6947867524049645729.post-71907669747990808142012-06-13T09:56:00.002+03:002012-06-13T09:56:31.692+03:00How to create dropdown menu in ribbon Crm 2011To create a dropdown menu in ribbon for crm 2011 you have to use the FlyoutAnchor element. <br />
<br />
To add it in the solution you have to first export the solution from CRM 2011 and open for editing the Configuration.xml file.<br />
<br />
Steps to build the element in the configuration file:<br />
<br />
1)In the CustomActions tag of the RibbonDiffXml you have to add the code:<br />
<span style="font-size: x-small;"> <CustomActions><br /> <CustomAction Id="Status" Location="Mscrm.Form.new_area.MainTab.Save.Controls._children"><br /> <CommandUIDefinition><br /> <FlyoutAnchor Id="ISV.AreaStatusFlyout" Sequence="100" Command="Mscrm.Enabled" Image16by16="/_imgs/placeholders/ribbon_placeholder_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" LabelText="Status" Alt="Status" PopulateOnlyOnce="false" PopulateDynamically="false" TemplateAlias="isv"><br /> <Menu Id="ISV.DynamicAreaStatus"><br /> <MenuSection Id="ISV.AreaStatus.MenuSection\" Sequence="101"><br /> <Controls Id="ISV.AreaStatus.Controls"><br /> <Button Id="ISV.AreaStatus.Button1" Command="ISV.AreaStatus.Open" Sequence="102" LabelText="Open" Alt="Open" /><br /> <Button Id="ISV.AreaStatus.Button2" Command="ISV.AreaStatus.Active" Sequence="103" LabelText="Active" Alt="Active" /><br /> <Button Id="ISV.AreaStatus.Button3" Command="ISV.AreaStatus.Closed" Sequence="104" LabelText="Closed" Alt="Closed" /><br /> </Controls><br /> </MenuSection><br /> </Menu><br /> </FlyoutAnchor><br /> </CommandUIDefinition><br /> </CustomAction></span><br />
<br />
2) In the CommandDefinitions section of the RibbonDiffXml you have to add the commands for each button inserted in FlyoutAnchor.<br />
<br />
<span style="font-size: x-small;"> <CommandDefinitions><br /> <CommandDefinition Id="ISV.AreaStatus.Open"><br /> <EnableRules /><br /> <DisplayRules /><br /> <Actions><br /> <JavaScriptFunction FunctionName="AreaStatus_Open" Library="$webresource:new_jsFile.js"><br /> <CrmParameter Value="FirstPrimaryItemId" /><br /> </JavaScriptFunction><br /> </Actions><br /> </CommandDefinition><br /> <CommandDefinition Id="ISV.AreaStatus.Active"><br /> <EnableRules /><br /> <DisplayRules /><br /> <Actions><br /> <JavaScriptFunction FunctionName="AreaStatus_Activ" Library="$webresource:new_</span><span style="font-size: x-small;">jsFile</span><span style="font-size: x-small;">.js"><br /> <CrmParameter Value="FirstPrimaryItemId" /><br /> </JavaScriptFunction><br /> </Actions><br /> </CommandDefinition></span><span style="font-size: x-small;"><br /> <CommandDefinition Id="ISV.AreaStatus.Closed"><br /> <EnableRules /><br /> <DisplayRules /><br /> <Actions><br /> <JavaScriptFunction FunctionName="Close" Library="$webresource:new_</span><span style="font-size: x-small;">jsFile</span><span style="font-size: x-small;">.js"><br /> <CrmParameter Value="FirstPrimaryItemId" /><br /> </JavaScriptFunction><br /> </Actions><br /> </CommandDefinition><br /> </CommandDefinitions></span><br />
<br />
For each button i assigned a function from the javascript file called: new_jsFile.js.<br />
<br />
Save the Customizations.xml File and upload it to the CRM.scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com0tag:blogger.com,1999:blog-6947867524049645729.post-59756197471136703022012-06-01T08:03:00.003+03:002012-06-01T08:03:57.037+03:00Remove item from picklist programatically in CRM 2011 with javascriptIn Dynamics CRM 2011, I have a pick-list for my Opportunities with the follwing options, which influences my Sales Pipeline:<br />
1 - Prospect<br />
2 - Proposal<br />
3 - Negotiation<br />
<br />
What i had to do is to filter the picklist so that only some of the options to be available, not all of them in the same time, ensuring that the user can't jump stages (jumping from 1 to 3), and that
the user can't go backwards (from 2 to 1, from 3 to 2 or 1).<br />
<br />
The code is:<br />
<br />
<div style="background-color: white; color: black;">
<pre><span style="color: green;">// Get value of Pipeline Phase set by user</span>
<span style="color: blue;">if</span> (Xrm.Page.getAttribute(<span style="color: #a31515;">"new_salesstagecode"</span>).getSelectedOption() != <span style="color: blue;">null</span>)
{<span style="color: blue;">var</span> val_salesstagecode = Xrm.Page.getAttribute(<span style="color: #a31515;">"new_salesstagecode"</span>).getSelectedOption().value;}
<span style="color: blue;">else</span> {<span style="color: blue;">var</span> val_salesstagecode = <span style="color: blue;">null</span>;}
</pre>
</div>
<div style="background-color: white; color: black;">
<pre><span style="color: green;">// Filter Pipeline Phase picklist to avoid users jumping stages</span>
<span style="color: blue;">if</span> (val_salesstagecode == 1)
{ Xrm.Page.getControl(<span style="color: #a31515;">"new_salesstagecode"</span>).removeOption(3); }
<span style="color: blue;">else</span> <span style="color: blue;">if</span> (val_salesstagecode == 2)
{ Xrm.Page.getControl(<span style="color: #a31515;">"new_salesstagecode"</span>).removeOption(1); }
<span style="color: blue;">else</span> <span style="color: blue;">if</span> (val_salesstagecode == 3)
{
Xrm.Page.getControl(<span style="color: #a31515;">"new_salesstagecode"</span>).removeOption(1);
Xrm.Page.getControl(<span style="color: #a31515;">"new_salesstagecode"</span>).removeOption(2);
}
</pre>
</div>scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com1tag:blogger.com,1999:blog-6947867524049645729.post-76997639210497321692012-05-30T11:56:00.001+03:002012-05-30T11:57:57.542+03:00Pass parameters to web page from customizationWhen you want to open a web page from a cutom button in CRM 2011, there are options so that you can send parameters to the web page.<br />
<br />
To do this follow the steps:<br />
<br />
1) Open the customizations.xml exported from the solution<br />
2) Find the associated <span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt; line-height: 115%;"><CommandDefinition></span> of the button in <span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt; line-height: 115%;"><RibbonDiffXml>/<</span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt; line-height: 115%;">CommandDefinitions></span><br />
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt; line-height: 115%;">3)Insert the Action statement like this:</span><br />
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; margin-top: 12.0pt; text-indent: -.25in;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt;"><Actions></span><br />
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt;"><Url
Address="$webresource:new_/Test.html"
PassParams="true" <b>WinParams="height=400, width=500,toolbar=no,
menubar=no,location=no"></b></span><span style="color: black; font-family: "Times New Roman","serif"; font-size: 7pt;"> </span><br />
<span style="color: black; font-family: "Times New Roman","serif"; font-size: 7pt;"> </span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt;"></Url></span></div>
<div class="MsoNormal" style="background: none repeat scroll 0% 0% white; line-height: normal; margin: 12pt 0in; text-indent: -0.25in;">
<span style="color: black; font-family: "Courier New"; font-size: 10pt;"></span><span style="color: black; font-family: "Times New Roman","serif"; font-size: 7pt;"> </span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 9.5pt;"></Actions></span><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"></span></div>scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com0tag:blogger.com,1999:blog-6947867524049645729.post-16927490781918701022012-05-29T12:01:00.001+03:002012-05-29T12:17:08.312+03:00Filter lookup programmatically using javascript on CRM formTo filter the view behind a lookup so this it will retrieve only some of the elements based on a filter it can be done follwing the steps:<br />
<br />
1)Set the id Guid of the View, it can be a random Guid. <br />
var <b>viewId </b>= "{10109D21-27F7-4828-B131-1B5E972C4718}"; //Any Guid is fine.<br />
<br />
2)Set the entity name to be filtered<br />
var <b>entityName </b>= "new_test";// Entity to be filtered <br />
<br />
3)Set the name for the custom view<br />
var <b>viewDisplayName </b>= "Test View"; // Custom name for the lookup window<br />
<br />
4)Create the query that you want to retrieve. You can use Advanced Search to make it more quickly, or you can build it yourself .<br />
<br />
var <b>fetchXML </b>= "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";<br />
fetchXML += "<entity name='new_test'>";<br />
fetchXML += "<attribute name='new_name'/>";<br />
fetchXML += "<attribute name='new_code' />";<br />
fetchXML += "<filter type='and'>";<br />
fetchXML += "<condition attribute='new_name' operator='like' value='%abc%'/>";<br />
<br />
fetchXML += "</filter>";<br />
<br />
fetchXML += "</entity>";<br />
fetchXML += "</fetch>";<br />
<br />
5)Create the layout which will be displayed in the lookup<br />
<br />
<br />
var <b>layoutXML </b>= "<grid name='resultset' object='1' jump='new_primary' select='1' icon='1' preview='1'>";<br />
layoutXML += "<row name='result' id='new_name'>";<br />
layoutXML += "<cell name='new_code' width='150' />";<br />
layoutXML += "</row>";<br />
layoutXML += "</grid>";<br />
<br />
6) Assign the custom view to the desired control:<br />
Xrm.Page.getControl("new_testControl").addCustomView(viewId, entityName, viewDisplayName, fetchXML , layoutXML, true);<br />
<br />
The full script is: <br />
<br />
var <b>viewId </b>= "{10109D21-27F7-4828-B131-1B5E972C4718}"; //Any Guid is fine.<br />
var <b>entityName </b>= "new_test";// Entity to be filtered<br />
var <b>viewDisplayName </b>= "Test View"; // Custom name for the lookup window<br />
var <b>fetchXML </b>= "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";<br />
fetchXML += "<entity name='new_test'>";<br />
fetchXML += "<attribute name='new_name'/>";<br />
fetchXML += "<attribute name='new_code' />";<br />
fetchXML += "<filter type='and'>";<br />
fetchXML += "<condition attribute='new_name' operator='like' value='%abc%'/>";<br />
<br />
fetchXML += "</filter>";<br />
<br />
fetchXML += "</entity>";<br />
fetchXML += "</fetch>";<br />
<br />
var <b>layoutXML </b>= "<grid name='resultset' object='1' jump='new_primary' select='1' icon='1' preview='1'>";<br />
layoutXML += "<row name='result' id='new_name'>";<br />
layoutXML += "<cell name='new_code' width='150' />";<br />
layoutXML += "</row>";<br />
layoutXML += "</grid>";<br />
<br />
Xrm.Page.getControl("new_testControl").addCustomView(viewId, entityName, viewDisplayName, fetchXML , layoutXML, true);scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com0tag:blogger.com,1999:blog-6947867524049645729.post-28234920767072096732012-04-25T20:59:00.003+03:002012-06-07T11:36:33.923+03:00How to force CRM Save after javascript update on formIf you made an update of the form on a disabled field in CRM 2011, after the Save button was pushed you realized that the information wasn't saved.<br />
<br />
<br />
What you have to do is to set the field as "dirty", so that CRM knows the field value has changed and should be submitted in the update of the record. Meaning that you have to add also a javascript code so that change will be taken into the save of the form.<br />
<br />
<br />
In CRM 4.0 this was done by:<br />
crmForm.all.[fieldname].ForceSubmit = true;<br />
<br />
In CRM 2011 this is done by:<br />
Xrm.Page.getAttribute("new_field").setSubmitMode("always");<br />
<br />
This should force CRM to include the field when updating the record instead of ignoring the update.scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com0tag:blogger.com,1999:blog-6947867524049645729.post-4989796236798828692012-04-25T20:49:00.000+03:002012-04-25T20:50:01.051+03:00How to set Default Area for CRM 2011 userIf you want to change the default area for a Microsoft CRM Dynamics 2011 user, you can't do it by using the Options Menu from CRM 2011.<br />
<br />
What you have to do is to modify the organization database by using a sql script.<br />
<br />
So if you want to make ‘Announcements’ as default page for all the users in that case just run this query under your organization database and after that reset IIS.<br />
<br />
<b>update UserSettingsBase set Homepagearea=’Workplace’,Homepagesubarea=’nav_news’</b>scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com0tag:blogger.com,1999:blog-6947867524049645729.post-70653459514616722922012-04-25T20:39:00.000+03:002012-05-31T08:47:55.480+03:00Refresh tab programmatically in CRM 2011 using javascriptIn CRM 2011 if you want to refresh a tab in the entity form you have yo use some javascript code.<br />
<br />
To do this you have to find the id of the tab. The ids are like: tab0Tab, tab1Tab...in order of appearence in the form.<br />
<br />
So what you have to do is to create a javascript file in which to insert the following function:<br />
<br />
function changeTab()<br />
{var link=document.getElementById('tab0Tab');<br />
link.onclick=function()<br />
{<br />
window.location.reload(true);<br />
loadArea('areaForm');<br />
crmForm.GetTab($get('tab0', crmForm), true);<br />
}<br />
}<br />
<br />
And after that to insert the function on the OnLoad event of the page.<br />
<br />
And that's it all. After that when you'll press on the tab you selected in the function the form will be refreshed.<br />
<br />scrumhttp://www.blogger.com/profile/06280580934510217092noreply@blogger.com1