To create a dropdown menu in ribbon for crm 2011 you have to use the FlyoutAnchor element.
To add it in the solution you have to first export the solution from CRM 2011 and open for editing the Configuration.xml file.
Steps to build the element in the configuration file:
1)In the CustomActions tag of the RibbonDiffXml you have to add the code:
<CustomActions>
<CustomAction Id="Status" Location="Mscrm.Form.new_area.MainTab.Save.Controls._children">
<CommandUIDefinition>
<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">
<Menu Id="ISV.DynamicAreaStatus">
<MenuSection Id="ISV.AreaStatus.MenuSection\" Sequence="101">
<Controls Id="ISV.AreaStatus.Controls">
<Button Id="ISV.AreaStatus.Button1" Command="ISV.AreaStatus.Open" Sequence="102" LabelText="Open" Alt="Open" />
<Button Id="ISV.AreaStatus.Button2" Command="ISV.AreaStatus.Active" Sequence="103" LabelText="Active" Alt="Active" />
<Button Id="ISV.AreaStatus.Button3" Command="ISV.AreaStatus.Closed" Sequence="104" LabelText="Closed" Alt="Closed" />
</Controls>
</MenuSection>
</Menu>
</FlyoutAnchor>
</CommandUIDefinition>
</CustomAction>
2) In the CommandDefinitions section of the RibbonDiffXml you have to add the commands for each button inserted in FlyoutAnchor.
<CommandDefinitions>
<CommandDefinition Id="ISV.AreaStatus.Open">
<EnableRules />
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="AreaStatus_Open" Library="$webresource:new_jsFile.js">
<CrmParameter Value="FirstPrimaryItemId" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
<CommandDefinition Id="ISV.AreaStatus.Active">
<EnableRules />
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="AreaStatus_Activ" Library="$webresource:new_jsFile.js">
<CrmParameter Value="FirstPrimaryItemId" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
<CommandDefinition Id="ISV.AreaStatus.Closed">
<EnableRules />
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="Close" Library="$webresource:new_jsFile.js">
<CrmParameter Value="FirstPrimaryItemId" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
</CommandDefinitions>
For each button i assigned a function from the javascript file called: new_jsFile.js.
Save the Customizations.xml File and upload it to the CRM.
Crm Dynamics Blog
Wednesday, June 13, 2012
Friday, June 1, 2012
Remove item from picklist programatically in CRM 2011 with javascript
In Dynamics CRM 2011, I have a pick-list for my Opportunities with the follwing options, which influences my Sales Pipeline:
1 - Prospect
2 - Proposal
3 - Negotiation
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).
The code is:
1 - Prospect
2 - Proposal
3 - Negotiation
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).
The code is:
// Get value of Pipeline Phase set by user if (Xrm.Page.getAttribute("new_salesstagecode").getSelectedOption() != null) {var val_salesstagecode = Xrm.Page.getAttribute("new_salesstagecode").getSelectedOption().value;} else {var val_salesstagecode = null;}
// Filter Pipeline Phase picklist to avoid users jumping stages if (val_salesstagecode == 1) { Xrm.Page.getControl("new_salesstagecode").removeOption(3); } else if (val_salesstagecode == 2) { Xrm.Page.getControl("new_salesstagecode").removeOption(1); } else if (val_salesstagecode == 3) { Xrm.Page.getControl("new_salesstagecode").removeOption(1); Xrm.Page.getControl("new_salesstagecode").removeOption(2); }
Wednesday, May 30, 2012
Pass parameters to web page from customization
When 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.
To do this follow the steps:
1) Open the customizations.xml exported from the solution
2) Find the associated <CommandDefinition> of the button in <RibbonDiffXml>/<CommandDefinitions>
3)Insert the Action statement like this:
To do this follow the steps:
1) Open the customizations.xml exported from the solution
2) Find the associated <CommandDefinition> of the button in <RibbonDiffXml>/<CommandDefinitions>
3)Insert the Action statement like this:
<Actions>
<Url Address="$webresource:new_/Test.html" PassParams="true" WinParams="height=400, width=500,toolbar=no, menubar=no,location=no">
</Url>
<Url Address="$webresource:new_/Test.html" PassParams="true" WinParams="height=400, width=500,toolbar=no, menubar=no,location=no">
</Url>
</Actions>
Tuesday, May 29, 2012
Filter lookup programmatically using javascript on CRM form
To 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:
1)Set the id Guid of the View, it can be a random Guid.
var viewId = "{10109D21-27F7-4828-B131-1B5E972C4718}"; //Any Guid is fine.
2)Set the entity name to be filtered
var entityName = "new_test";// Entity to be filtered
3)Set the name for the custom view
var viewDisplayName = "Test View"; // Custom name for the lookup window
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 .
var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXML += "<entity name='new_test'>";
fetchXML += "<attribute name='new_name'/>";
fetchXML += "<attribute name='new_code' />";
fetchXML += "<filter type='and'>";
fetchXML += "<condition attribute='new_name' operator='like' value='%abc%'/>";
fetchXML += "</filter>";
fetchXML += "</entity>";
fetchXML += "</fetch>";
5)Create the layout which will be displayed in the lookup
var layoutXML = "<grid name='resultset' object='1' jump='new_primary' select='1' icon='1' preview='1'>";
layoutXML += "<row name='result' id='new_name'>";
layoutXML += "<cell name='new_code' width='150' />";
layoutXML += "</row>";
layoutXML += "</grid>";
6) Assign the custom view to the desired control:
Xrm.Page.getControl("new_testControl").addCustomView(viewId, entityName, viewDisplayName, fetchXML , layoutXML, true);
The full script is:
var viewId = "{10109D21-27F7-4828-B131-1B5E972C4718}"; //Any Guid is fine.
var entityName = "new_test";// Entity to be filtered
var viewDisplayName = "Test View"; // Custom name for the lookup window
var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXML += "<entity name='new_test'>";
fetchXML += "<attribute name='new_name'/>";
fetchXML += "<attribute name='new_code' />";
fetchXML += "<filter type='and'>";
fetchXML += "<condition attribute='new_name' operator='like' value='%abc%'/>";
fetchXML += "</filter>";
fetchXML += "</entity>";
fetchXML += "</fetch>";
var layoutXML = "<grid name='resultset' object='1' jump='new_primary' select='1' icon='1' preview='1'>";
layoutXML += "<row name='result' id='new_name'>";
layoutXML += "<cell name='new_code' width='150' />";
layoutXML += "</row>";
layoutXML += "</grid>";
Xrm.Page.getControl("new_testControl").addCustomView(viewId, entityName, viewDisplayName, fetchXML , layoutXML, true);
1)Set the id Guid of the View, it can be a random Guid.
var viewId = "{10109D21-27F7-4828-B131-1B5E972C4718}"; //Any Guid is fine.
2)Set the entity name to be filtered
var entityName = "new_test";// Entity to be filtered
3)Set the name for the custom view
var viewDisplayName = "Test View"; // Custom name for the lookup window
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 .
var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXML += "<entity name='new_test'>";
fetchXML += "<attribute name='new_name'/>";
fetchXML += "<attribute name='new_code' />";
fetchXML += "<filter type='and'>";
fetchXML += "<condition attribute='new_name' operator='like' value='%abc%'/>";
fetchXML += "</filter>";
fetchXML += "</entity>";
fetchXML += "</fetch>";
5)Create the layout which will be displayed in the lookup
var layoutXML = "<grid name='resultset' object='1' jump='new_primary' select='1' icon='1' preview='1'>";
layoutXML += "<row name='result' id='new_name'>";
layoutXML += "<cell name='new_code' width='150' />";
layoutXML += "</row>";
layoutXML += "</grid>";
6) Assign the custom view to the desired control:
Xrm.Page.getControl("new_testControl").addCustomView(viewId, entityName, viewDisplayName, fetchXML , layoutXML, true);
The full script is:
var viewId = "{10109D21-27F7-4828-B131-1B5E972C4718}"; //Any Guid is fine.
var entityName = "new_test";// Entity to be filtered
var viewDisplayName = "Test View"; // Custom name for the lookup window
var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXML += "<entity name='new_test'>";
fetchXML += "<attribute name='new_name'/>";
fetchXML += "<attribute name='new_code' />";
fetchXML += "<filter type='and'>";
fetchXML += "<condition attribute='new_name' operator='like' value='%abc%'/>";
fetchXML += "</filter>";
fetchXML += "</entity>";
fetchXML += "</fetch>";
var layoutXML = "<grid name='resultset' object='1' jump='new_primary' select='1' icon='1' preview='1'>";
layoutXML += "<row name='result' id='new_name'>";
layoutXML += "<cell name='new_code' width='150' />";
layoutXML += "</row>";
layoutXML += "</grid>";
Xrm.Page.getControl("new_testControl").addCustomView(viewId, entityName, viewDisplayName, fetchXML , layoutXML, true);
Wednesday, April 25, 2012
How to force CRM Save after javascript update on form
If 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.
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.
In CRM 4.0 this was done by:
crmForm.all.[fieldname].ForceSubmit = true;
In CRM 2011 this is done by:
Xrm.Page.getAttribute("new_field").setSubmitMode("always");
This should force CRM to include the field when updating the record instead of ignoring the update.
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.
In CRM 4.0 this was done by:
crmForm.all.[fieldname].ForceSubmit = true;
In CRM 2011 this is done by:
Xrm.Page.getAttribute("new_field").setSubmitMode("always");
This should force CRM to include the field when updating the record instead of ignoring the update.
How to set Default Area for CRM 2011 user
If 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.
What you have to do is to modify the organization database by using a sql script.
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.
update UserSettingsBase set Homepagearea=’Workplace’,Homepagesubarea=’nav_news’
What you have to do is to modify the organization database by using a sql script.
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.
update UserSettingsBase set Homepagearea=’Workplace’,Homepagesubarea=’nav_news’
Refresh tab programmatically in CRM 2011 using javascript
In CRM 2011 if you want to refresh a tab in the entity form you have yo use some javascript code.
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.
So what you have to do is to create a javascript file in which to insert the following function:
function changeTab()
{var link=document.getElementById('tab0Tab');
link.onclick=function()
{
window.location.reload(true);
loadArea('areaForm');
crmForm.GetTab($get('tab0', crmForm), true);
}
}
And after that to insert the function on the OnLoad event of the page.
And that's it all. After that when you'll press on the tab you selected in the function the form will be refreshed.
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.
So what you have to do is to create a javascript file in which to insert the following function:
function changeTab()
{var link=document.getElementById('tab0Tab');
link.onclick=function()
{
window.location.reload(true);
loadArea('areaForm');
crmForm.GetTab($get('tab0', crmForm), true);
}
}
And after that to insert the function on the OnLoad event of the page.
And that's it all. After that when you'll press on the tab you selected in the function the form will be refreshed.
Subscribe to:
Posts (Atom)