Microsoft Dynamics CRM 2011 Running javascript on IE F12 developer tool
This way it is possible to check javascript in run time on the form.
1) Open some form in the crm.
2) Press F12 -> Open the IE F12 developer tools
3) Open script tab
3) type
Xrm = document.frames["contentIFrame"].Xrm;
Or
Xrm = frames[0].Xrm
4) Run your code
Monday, June 25, 2012
Friday, June 15, 2012
Microsoft Dynamics CRM 2011 Create new case from account's homepage ribbon
Microsoft Dynamics CRM 2011 Create new case from account's homepage ribbon Or cut the clicks
The idea behind it was to cut the time for creating new case, Instead of going to account homepage, opening the account form, click on case sub grid and then create the case, It will be just go to account homepage choose the account and create new case.
This is a real time saver.
1) Create new solution.
2) Add new web resource type JavaScript
2) Add new web resource type JavaScript
var CASE_URL = "/main.aspx?etc=112&extraqs=%3f_CreateFromId%3d%257b{ACCOUNTID}%257d%26_CreateFromType%3d1&pagetype=entityrecord";
CreateNewCaseFromAccount = function(id)
{
//get
accountid
var
nakedId = id.replace("{", "").replace("}",
"");
var
caseUrl = CASE_URL.replace("{ACCOUNTID}", nakedId);
var
caseUrl = Xrm.Page.context.prependOrgName(caseUrl);
window.open(caseUrl);
}
3) Add button to account's homepage
ribbon to call CreateNewCaseFromAccount function. Two ways for adding the
button to account.
1) Use Ribbon workbench.
2) The old fashion way, do it yourself.
1) Use Ribbon workbench.
2) The old fashion way, do it yourself.
a. Add account to solution.
b. Export solution.
c. Extract the solution file.
d. Open customizations.xml using
your favorite notepad
e.Add the button to the
RibbonDiffXml:
<RibbonDiffXml>
<CustomActions>
<CustomAction
Id="HomepageGrid.account.MainTab.Actions.CreateNewCase.CustomAction"
Location="Mscrm.HomepageGrid.account.MainTab.Actions.Controls._children"
Sequence="41">
<CommandUIDefinition>
<Button Id="HomepageGrid.account.MainTab.Actions.CreateNewCase"
Command="HomepageGrid.account.MainTab.Actions.CreateNewCase.Command"
Sequence="20" ToolTipTitle="Create New Case"
LabelText="Create New Case" ToolTipDescription="Create New
Case" TemplateAlias="o1" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates
Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition
Id="HomepageGrid.account.MainTab.Actions.CreateNewCase.Command">
<EnableRules>
<EnableRule
Id="HomepageGrid.account.MainTab.Actions.CreateNewCase.Command.EnableRule.SelectionCountRule"
/>
</EnableRules>
<DisplayRules />
<Actions>
<JavaScriptFunction
FunctionName="CreateNewCaseFromAccount"
Library="$Webresource:new_/CreateNewCase/CreateNewCase.js">
<CrmParameter
Value="FirstSelectedItemId" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules>
<EnableRule Id="HomepageGrid.account.MainTab.Actions.CreateNewCase.Command.EnableRule.SelectionCountRule">
<SelectionCountRule
AppliesTo="SelectedEntity" Maximum="1"
Minimum="1" Default="true" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>
f. Import the solution back and publish.
Good luck.
This post was written before Dynamics CRM 2011 RU 8 and the new Xrm.utility, It changes only the way of opening new form the basic idea of this post stays the same.
For more information about Xrm.utility go to
http://jonasrapp.cinteros.se/2012/08/xrmutility-methods-in-ms-dynamics-crm.html
or many other posts that explains the new functions available.
This post was written before Dynamics CRM 2011 RU 8 and the new Xrm.utility, It changes only the way of opening new form the basic idea of this post stays the same.
For more information about Xrm.utility go to
http://jonasrapp.cinteros.se/2012/08/xrmutility-methods-in-ms-dynamics-crm.html
or many other posts that explains the new functions available.
Thursday, June 14, 2012
Dynamics CRM 2011 readonly form javascript
Dynamics CRM 2011 read-only form JavaScript.
With it does:
1) Hides the content of
a form with transparent div.
Pros:
1) Easier way to disable
all the controls of the form and enabling them while keeping all the logic of
the form (pre disabled controls will keep be disabled).
2) It's faster than
going over all the controls and disabling them.
Cons:
1) Partially Unsupported
How to guide:
1) Create new JavaScript
web resource
2) Add this code:
//Disable all form controls
DisableForm = function() {
var iframeDoc = document;
var iframeBody =
document.getElementById("crmFormTabContainer");
hideContent(iframeDoc, iframeBody);
Xrm.Page.ui.tabs.forEach(
function(tab, index)
{
Xrm.Page.ui.tabs.get(index).add_tabStateChange(function()
{
var iframeDoc = document;
var iframeBody =
document.getElementById("crmFormTabContainer");
var roSpan =
document.getElementById("readonlySpan");
if (roSpan != null) {
iframeBody.removeChild(roSpan);
}
hideContent(iframeDoc, iframeBody);
});
}
);
}
hideContent = function(htmlDocument,
htmlElement) {
var roSpan =
htmlDocument.createElement("div");
roSpan.id = "readonlySpan";
var roStyle =
"position:absolute;";
roStyle += "z-index:1;";
roStyle += "left:0px;";
roStyle += "top:0px;";
roStyle +=
"height:"+htmlElement.scrollHeight+"px;";
roStyle += "text-align:center;";
roStyle += "font:72px Tahoma;";
roStyle += "opacity:0.20;";
roStyle += "-moz-opacity:0.20;";
roStyle += '-ms-filter:
"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";';
roStyle += 'filter:
"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)"';
roStyle += "filter: alpha(opacity=20);";
roStyle += "background-color:white;";
roSpan.style.cssText = roStyle;
htmlElement.appendChild(roSpan);
roSpan.innerHTML = "<div
style='margin-top:30%;height:100px;'>READ ONLY</div>";
roSpan.style.zoom = 1;
}
//Enable all form control keep readonly /
disable logic.
EnableForm = function() {
var iframeBody =
document.getElementById("crmFormTabContainer");
var roSpan =
document.getElementById("readonlySpan");
if (roSpan != null) {
iframeBody.removeChild(roSpan);
}
}
3) Add DisableForm function
to onload event of the form.
Good luck.
Subscribe to:
Posts (Atom)