Showing posts with label Unsupported. Show all posts
Showing posts with label Unsupported. Show all posts

Oct 4, 2012

Advanced find – Select all the records of all the pages

Ribbon of advanced find result view

 
Ribbon of the result pane of advanced find view is same as Subgrid ribbon. Yep it is! So whatever the ribbon modifications you do with the format of  “Mscrm.SubGrid.<entityname>” is being applied for this ribbon. So you are free to do anything with any custom button by executing a Javascript as I explained in my previous post. Check it here.

Now we know, we can pass different parameters to our method, but obviously, favourite would be the passing of Ids of selected records. So we are good to do any operation for those records.

Reading the current grid VS reading the full result set

Anyway, none of these parameters leads us to read all the records of all the pages of the result. Our operations are restricted to current grid. Current grid could hold maximum records of 250, with least 25, depending on your settings.


If our result consists of more records and we need to do a batch operation for all of them we are not helped. One approach would be to save the view after selecting the criteria and again read the relevant fetch from SavedQueryBase. Problem of this approach is one has to save it manually with a predetermined name. (Name is to be used when querying by the programme)

Now this is a way of reading the relevant Fetch XML without saving, from the result pane. I urge this is an unsupported method, but it works.

var _XML = document.getElementById("fetchXml");
alert(_XML.value);

Now we have the fetch used to read the data for advanced find, so we are ready to do any operation for entire result set.

Jul 16, 2012

Disable ribbon button through onload JavaScript

CRM 2011 is giving full control of custom button through ribbon concept over ISV configuration concept of CRM 4.0. Here I have mention how to enable/disable button according to rules we define.

Here, rule is a straightforward one. For example, if we need to disable a button depending on logged in user’s team, I am still unable to address through a rule definition. Till I find it I found a way of doing it through onload JavaScript.

Ribbon item behaves according to a defined style. What I do is manipulating the style according to my need. Here I need to disable a particular button if the user is not in “Admin” team.
First I grab the id of the button. I assume you know how to do that by F12 function as shown below.


Now replace the standard style of that button by standard style of the disabled button as required.

if (!userIsInTeam("Admin"))
{
 if (window.top.document.getElementById('<ID>'))
 {
 var _id = window.top.document.getElementById('<ID>');
 var str = _id.outerHTML;
 var str1 = str.replace("ms-cui-ctl-large", "ms-cui-ctl-large ms-cui-disabled");
 _id.outerHTML = unescape(str1);
 }
}

I urge this is not the best way, but this works.
If I manage to find a way to define a rule in XML, I am publishing it. If you find first, please share it for me too.

May 10, 2012

Custom button: Must show both icon and title!

CRM form has a toolbar that contains most needed built in buttons such as SAVE, CLOSE and etc. It also allows you to create your own action buttons too. This is pretty straight forward. Usually, we are allowed to have icon and title for those buttons along with tooltip.

If we add number of custom buttons, there could be a space problem since width of the toolbar is limited. CRM is doing something smart to show only icon when there is an issue of space. You will sometimes notice that you see both icon and title only when a form is maximized.


Even if we add more custom buttons through ISV, we can hide them according to the current status of the form when loading. We discussed it here. However, this doesn’t release any space.  In fact, hiding some of the custom buttons through JavaScript doesn’t solve the space issue. This results in showing only the icons for the custom buttons while a lot of free space is visible.

If we need to show both icon and title necessarily, there is no simple recommended way. However I tried one out-of-box method that worked for me. This is not a Microsoft supported way.

It contains below three steps.

1) Create images that contains icon and text both

Even you are not a graphic designer; there is an easy way to do this. Just add the custom button (with title) to another test entity and get a screen print which will give you the chance of creating a nice image that got the CRM look and feel. Then load this to usual CRM image folder. (Program Files\Microsoft Dynamics CRM\CRMWeb\_imgs)


2) Change ISV entry

Now you need to do two changes to ISV entry as below.

<!--Original -->
<Button JavaScript="ReadySale();" Icon="/_imgs/ico_18_sales.gif" PassParams="1">
  <Titles>
     <Title LCID="1033" Text="Ready for Sale" />
  </Titles>
  <ToolTips>
     <ToolTip LCID="1033" Text="Ready for Sale" />
  </ToolTips>
</Button>

<!--Changed entry -->
<Button JavaScript="ReadySale();" Icon="/_imgs/ico_18_sales_EXT.gif" PassParams="1">
   <ToolTips>
        <ToolTip LCID="1033" Text="Ready for Sale" />
   </ToolTips>
</Button>

You need to replace the image name with your new one and remove the title tag. Obviously, if you keep the title tag, you will see the title twice if form toolbar stretches with enough space.

3) Ignore style of the button on loading

Now we should understand that CRM styles are applied to each and every component of the toolbar. So usually it doesn’t allow you to keep long text along with the icon. So you need to remove relevant style from the tag in onload event.

var _list = document.getElementsByTagName('LI');
var m = 0;
while (m < _list.length)
{
  if (_list[m].getAttribute('title') == 'Ready for Sale') 
  {
   var str = _list[m].outerHTML;
   var str1 = str.replace("ms-crm-Menu-ButtonFirst", "");
   _list[m].outerHTML = unescape(str1);
  }
  m = m + 1;
}

Mission accomplished!

Aug 11, 2011

Convert Appointments in to Opportunities without source campaign

You can convert Appointments in to Opportunities in Dynamics CRM and it is a handy feature. You can simply click convert activity button which result below pop-up window.


Here, source campaign comes as a required field in default. Sometimes users doesn’t use campaigns and don’t wish to see it as a required field accordingly. If are asked to change this, there is no proper way of doing it. When I play around the page code, I found some way of doing it (unsupported). You can see the page in below location;

\Program Files\Microsoft Dynamics CRM\CRMWeb\Activities\act_dlgs\convert_activity.aspx

You just have to add two lines to onload script as below.

function window.onload()
{
onSubjectInit();
cbLogResponse.checked = false; //added line 1
campaignCheckHandler();        //added line 2
}

Now source campaign is no more a required field by default.
Hope this will help you.

Jul 13, 2011

Deleting/ Renaming of System views

Though, deleting the system views is not possible, in most of the cases we need to do so. There is one unsupported way of doing it; actually hiding it. You got to modify a flag in relevant SQL table. Views are stored in a table called SavedQuery and you can simply see all the views of an entity by passing the entity type code to below query. (1 is for account)

select Name,* from SavedQuery where ReturnedTypeCode=1

Now for instance, if you need to delete (actually hide) view called “Accounts: No Orders in Last 6 Months”, simply set IsPrivate = 1 for relevant record as shown below.

update SavedQuery set IsPrivate = 1
where Name = 'Accounts: No Orders in Last 6 Months'

Then publish the entity.

Here, what really happens is converting the system view to a private one with no rights. Also you should be aware that, the change is not imported with customizations, but you got to do for each server. Anyway, you got to play safely since this is unsupported.

Swap System view name with new one
It was needed to create a new view with the name of an existing system view. In fact, particular system view was renamed and renamed the new view with system view name. Nothing seems wrong in steps, but this gives problems with importing the customizations. One of my colleagues found a way of doing it. Rename the System view and did a deployment. Then rename own new view with the name of the system view and do the second deployment. Problem is solved. Anyway, this doesn’t make deployment managers life easy, because he got to keep two versions of customizations for those entities.

Hope this will help you.

Jul 4, 2011

Hiding Menu Items from More Actions

I needed to remove the deactivation option from the Account entity. So I actually have to remove this from two separate menus. One is "More Action" section of the account grid. Other one is "Action" section appeared once account record is opened.

Below link gives a nice way of removing items from Action menu.
http://metrix.blogspot.com/2009/06/hiding-menu-items-from-top-menu-bar-in.html
Obviously, it can be called onLoad form of the account without any issue.

Removing items from Action menu of the grid is tricky, because we don’t know from where we can call a JavaScript to accomplish our task. After reading and researching I managed to solve this by calling a javaScript from the loading script in below page.

\Microsoft Dynamics CRM\CRMWeb\_root\HomePage.aspx

What is really cool here is, you have typecode in hand for your coding. Since I am interested in account entity, I checked its typecode (i.e. 1) and proceeded with my code. Id of the menu item relevant for deactivation was found through Developer Tools (pressing F12 as usual).

function window.onload()
{
 ...
 ...

 if (_currentTypeCode==1)
 { 
   if (document.all._MIdoActioncrmGrid1deactivate != null) 
   { document.all._MIdoActioncrmGrid1deactivate.style.display = "none";} 
 } 
 ..
}


This seems cool, yet not supported at all.. So please play safely and carefully.

Hope this will help.

Jun 19, 2011

Two default public views?

This is something you don’t see usually in Dynamics CRM 4.0. According to picture, it shows two default public view, which is against the norms. Surprisingly, this can happen rarely in CRM systems. This is unexplained.


What you have to do is, export the customization of particular entity and check for sections related to public views (Here I am strictly calling “Public” views; I want you to omit the Associate views, advanced find views and etc.) and find <isdefault name="Yes">1</isdefault> tag. You will find this for more than one Public View. You will have to change them to <isdefault name="No">0</isdefault>, except for the correct default public view.

Now import the customization and publish. You problem is solved.