function HideAssociatedViewButtons(areaPrefix, loadAreaId, buttonTitles,addAreaParams){
var navElement = document.getElementById(areaPrefix+loadAreaId);
if (navElement != null) {
navElement.onclick = function LoadAreaOverride(){
if(addAreaParams.length>0)
loadArea('area'+loadAreaId, addAreaParams[0]);
else
loadArea('area'+loadAreaId);
var iframeid='area' + loadAreaId + 'Frame';
HideViewButtons(document.getElementById(iframeid), buttonTitles);
}
}
}
function HideViewButtons(Iframe, buttonTitles) {
if (Iframe != null ) {
Iframe.onreadystatechange = function HideTitledButtons() {
if (Iframe.readyState == 'complete') {
var iFrame = frames[window.event.srcElement.id];
var liElements = iFrame.document.getElementsByTagName('li');
for (var j = 0; j < buttonTitles.length; j++) {
for (var i = 0; i < liElements.length; i++) {
if (liElements[i].getAttribute('title') == buttonTitles[j]) {
liElements[i].style.display = 'none';
break;
}
}
}
}
}
}
}
Показаны сообщения с ярлыком trick. Показать все сообщения
Показаны сообщения с ярлыком trick. Показать все сообщения
2009-12-21
Upgrade of javascript function to hide "Add Existing ..." button
I improved the source code for one of my previous post — Remove 'Add Existing...' button from associated view entities form.
Ярлыки:
javascript,
trick
2009-11-13
Passing parameters between MS CRM plugins
I was needed to pass a variable from one plugin to another. If you have a two plugin at pre and post stage registered for on entity, then you can use a SharedVariables context property. But, if every plugins is a different assembly, and they are registered for a different entities... So, when the first plugin is firing, the second, which is starting after that, needed to know some information for redirecting it logic to another way.
I had created some common assembly with helper methods and called it "Helper". Then I had created a static class with static variable and had put the value into it, at the first plugin execution runtime. In the second plugin I just get the value from the static common variable.
And nothing about read\write DB operations.
Helper assembly.
First firing plugin code
Second firing plugin code
I had created some common assembly with helper methods and called it "Helper". Then I had created a static class with static variable and had put the value into it, at the first plugin execution runtime. In the second plugin I just get the value from the static common variable.
And nothing about read\write DB operations.
Helper assembly.
namespace Helper
{
public static class Keeper
{
private static bool _UpdateOppAfterHistory = true;
public static bool UpdateOppAfterHistory
{
get { return _UpdateOppAfterHistory; }
set { _UpdateOppAfterHistory = value; }
}
}
public class OpportunityHelper
{ ... }
}
First firing plugin code
Keeper.UpdateOppAfterHistory = false;
OpportunityHelper.CreateOpportunityHistory(Opp,crmService);
// removing the flag to the back
Keeper.UpdateOppAfterHistory = true;
Second firing plugin code
// common shared variable analysis
bool UpdateOppAfterHistory = Keeper.UpdateOppAfterHistory;
if (UpdateOppAfterHistory)
{ ... }
2009-11-09
Salesorder Fulfill state
I was trying to catch the Fulfill state of sales order and my try was successful, with registering plugin to Update message at Child pipeline. But there was a one little problem - you can't get the salesorderdetail thru service. I don't know why, but the simple code like in "Example 1" was falling down with Generic SQL error x80044150.
Then I was switch on the Fulfill Sdk Message and everything start working fine!
I have a question, why the Fulfill message has been unplugged from customization?
// Example 1
QueryByAttribute qba = new QueryByAttribute();
qba.EntityName = EntityName.salesorderdetail.ToString();
qba.ColumnSet = new AllColumns();
qba.Attributes = new string[] { "salesorderid" };
qba.Values = new object[] { soid };
BusinessEntityCollection bec = crmService.RetrieveMultiple(qba);
Then I was switch on the Fulfill Sdk Message and everything start working fine!
1. open up the SdkMessage view, filter by Name and find the SdkMessageId
2. open up the SdkMessageFilter view, filter by SdkMessageId you got from step 1.
3. change IsCustomProcessingStepAllowed to 'True'
update dbo.SdkMessageFilter set IsCustomProcessingStepAllowed=1 where SdkMessageId= (select top 1 SdkMessageId from dbo.SdkMessage where name ='Fulfill')
I have a question, why the Fulfill message has been unplugged from customization?
2009-10-12
Registering plugins for event on many-to-many entities
I found that from the box MS CRM 4.0 are not supported the events on many-to-many relationship entities(bridge entities). But Aaron Elder has hack it.
All you need is just register it at AssociateEntities or DiassociateEntities event with empty Primary and Secondary Entity fields.
http://consulting.ascentium.com/blog/crm/Post533.aspx
All you need is just register it at AssociateEntities or DiassociateEntities event with empty Primary and Secondary Entity fields.
-- ============================================================================
-- Enable Associate and Disassociate Plug-in Events Script v1.0
-- ----------------------------------------------------------------------------
-- (c) 2009 Aaron Elder
-- ============================================================================
-- DISCLAIMER:
-- This script is provided "AS IS" with no warranties, and confers no rights.
-- ============================================================================
-- While this is obviously "unsupported", I think the fact that these events
-- are not available is a bug and hopefully it will be fixed in a rollup.
-- ============================================================================
USE AscentiumCrmDev_MSCRM
GO
-- Find the deployments SDK Filter ID for the
-- Associate and Disassociate Entity SDK Messages
DECLARE @DisassociateEntitiesFilterId uniqueidentifier
DECLARE @AssociateEntitiesFilterId uniqueidentifier
SET @DisassociateEntitiesFilterId = (SELECT SdkMessageId FROM SdkMessageBase WHERE [Name] = 'DisassociateEntities')
SET @AssociateEntitiesFilterId = (SELECT SdkMessageId FROM SdkMessageBase WHERE [Name] = 'AssociateEntities')
-- Enable the Associate and Disassociate Filters to be valid for custom processing
-- Custom Processing means "you register plug-ins against it"
-- Note: We only do this for the "generic" (OTC == 0) case, just to be safer
UPDATE SdkMessageFilterBase SET IsCustomProcessingStepAllowed = 1
WHERE SdkMessageId = @DisassociateEntitiesFilterId AND PrimaryObjectTypeCode = 0
UPDATE SdkMessageFilterBase SET IsCustomProcessingStepAllowed = 1
WHERE SdkMessageId = @AssociateEntitiesFilterId AND PrimaryObjectTypeCode = 0
(C)http://consulting.ascentium.com/blog/crm/Post533.aspx
2009-10-07
Window redirect and close
This was the window that was opened from CRM form menu (ISV.Config.xml). The window has received some parameters and then redirected to another window, which is preparing and opening the MS Word document, but the pop-up window was still open - this is rude. So, I've closed it.
// call this code on body onload event
function redirect()
{
// needed URL of pop-up window or modify current location URL
window.opener.location = window.location.href.replace(/Default2/, "Default");
window.top.close();
}
Ярлыки:
javascript,
trick
2009-08-13
Remove 'Add Existing...' button from associated view entities form
I was found this code at Dave Hawes blog — http://blog.davehawes.com/post/2008/04/23/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx
This code should be added to onLoad event for the form of the entity where you want to hide buttons for the associated views of other entities.
Publishing it here for memory.
This code should be added to onLoad event for the form of the entity where you want to hide buttons for the associated views of other entities.
HideAssociatedViewButtons('new_account_new_accountclassificate', ['Добавить к этой записи существующий объект Классификация организации']);
function HideAssociatedViewButtons(loadAreaId, buttonTitles){
var navElement = document.getElementById('nav_' + loadAreaId);
if (navElement != null) {
navElement.onclick = function LoadAreaOverride() {
loadArea(loadAreaId);
HideViewButtons(document.getElementById(loadAreaId + 'Frame'), buttonTitles);
}
}
}
function HideViewButtons(Iframe, buttonTitles) {
if (Iframe != null ) {
Iframe.onreadystatechange = function HideTitledButtons() {
if (Iframe.readyState == 'complete') {
var iFrame = frames[window.event.srcElement.id];
var liElements = iFrame.document.getElementsByTagName('li');
for (var j = 0; j < buttonTitles.length; j++) {
for (var i = 0; i < liElements.length; i++) {
if (liElements[i].getAttribute('title') == buttonTitles[j]) {
liElements[i].style.display = 'none';
break;
}
}
}
}
}
}
}
Publishing it here for memory.
Ярлыки:
javascript,
trick
2009-06-04
Open any entity for edit
The universal URL to open any entity for edit is
http://server name/company name/CRMReports/viewer/drillopen.aspx?ID=objectguid&OTC=object type code
Object type code you can find at Microsoft Dynamics CRM SDK Entity Type Codes article.
Also like that:
http://server name/company name/CRMReports/viewer/drillopen.aspx?ID=objectguid&LogicalName=entity name (contact, account, e.t.c.)
http://server name/company name/CRMReports/viewer/drillopen.aspx?ID=objectguid&OTC=object type code
Object type code you can find at Microsoft Dynamics CRM SDK Entity Type Codes article.
Also like that:
http://server name/company name/CRMReports/viewer/drillopen.aspx?ID=objectguid&LogicalName=entity name (contact, account, e.t.c.)
Ярлыки:
trick
2009-01-21
How to close window without prompt. JavaScript.
For most of browsers work code like this:
But for IE7 will work this code:
window.opener = top;
window.close();
But for IE7 will work this code:
<script language=javascript>
function CloseWindow()
{
window.open('','_self','');
window.close();
}
</script>
<input type=button name="closebutton" value="Close" class="Button" onclick="CloseWindow()"/>
Ярлыки:
javascript,
trick
2008-10-30
Ownerid
Если сущность создавать программно и не заполнять поле ownerid, то MSCRM сам заполнит это поле Guid'ом пользователя, вызвавшего метод Create().
Ярлыки:
trick
2008-10-16
Скрытие стандартных ссылок в панели навигации сущности.
Узнаем наименование скрываемой ссылки, например с помощью IE DEV Tools.
И в форме сущности на событе OnLoad пишем следующий JavaScript:
И в форме сущности на событе OnLoad пишем следующий JavaScript:
if(document.all.navAddresses != undefined) {
document.all.navAddresses.parentNode.style.display = 'none';
}
Ярлыки:
javascript,
trick
2008-10-14
Закрытие окна CRM без подтверждения
Если вы хотите закрыть окно CRM без подтверждения, до вызова window.close() вызовите функцию crmForm.detachCloseAlert()
Ярлыки:
javascript,
trick
Подписаться на:
Сообщения (Atom)
