How can I add a bit of custom functionality to every CRM 2011 grid ribbon? - dynamics-crm-2011

I have a small bit of custom functionality which I need to run from each and every grid ribbon in CRM 2011. The functionality is in a JS web-resource and I can attach it to a button enable rule and it all works fine.
The issue is that I need this to run on every grid in CRM, but I'm struggling to find something in the ribbon which appears on every screen. I did try attaching it to one of the buttons in the Jewel menu, but this only fires if the user clicks on the "File" tab.
Any thoughts...?

The jewel menu button is a good idea.
Add an anonymous JavaScript function to the library you are adding to the jewel button.
This will run when the library is loaded, just after the page loads:
var whatever = 30; // maybe you do not need a parameter
(function (what) {
/* Do what you need to do */
}(whatever));

If it’s on premise I‘d inject my script to the ribbon.js or global.js or some other js and ping from there.
Another option, less intrusive , is to use a resource that runs in each and every form i.e. myframewrok.js. This resource can check for the opener and inject the script to the opener dynamically.
A third options might be to ping a web service using a plug-in registered on execute or retrieve multiple messages which fire repeatedly for any grid in the system.

In the end we attached it to the "Advanced Find" button as this appeared on every ribbon that we needed the functionality on. The Jewel menu did not seem to work for us as it only fired when the user actually clicked the "File" button.

Related

event listener when tab is changed

I need to store some data every time I move to some other tab in the same window or some other window using chrome storage API or even when a new tab is created. So, basically when my active tab is no longer active anymore.
So, for example, If I am on tab A and then I move to tab B(or create a new tab). When this switching happens from A to B, I need to save data from the website running in tab A. (I am getting the data from the site in tab A using content script.)
A more concrete example would be, suppose I am on YOutube site and I have a timeout timer running(using a content script). So when I move to some other site I want to stop the time get the current remaining time and save that. and if the other site is youtube too(in tab B) I would start the time from the previously saved value.
Is there any event listener for this? I looked at the documentation for chrome.tabs but could not figure it out.
I saw onActivated event listener but I am not sure if that would be useful.
Or is there some other way to achieve this?
Yes, according to the documentation onActivated:
Fires when the active tab in a window changes.
As an alternative, also can use content scripts that notify your extension when a page gain or loses focus with window.onfocus and window.onblur.
This way you'll be able to track the visibility of the tabs, though you should carefully select the required permission.

Chrome Extension, trigger click on the icon

I searched on Google and StackOverflow, and I was not able to find a solution to my problem (to my greatest surprise).
I'm looking to display the popup, exactly like when the user click on the icon of my extension, but via javascript.
The idea behind it is simple : On a specific page, I inject a button and add an event listener on it ("click"). When the user click on that button, I'd like to display the tooltip, simple as that :)
... but I can not find anything related to it. Any idea ?
Thank you in advance.
Opening the popup is impossible without user interaction. For good reason too, remember that no one likes popups that open themselves. What you can do is inject your popup onto the site the user is at, through a content script.
https://developer.chrome.com/extensions/content_scripts
As per your description,
On a specific page, I inject a button and add an event listener on it ("click"). When the user click on that button, I'd like to display the tooltip, simple as that :)
I think what you need is just chrome.pageAction, it's similar to browserAction, while represents actions that can be taken on the current page, but aren't applicable to all pages.

CRM 2011 Sub-Grid: Call JavaScript On-Click or On-Focus

How can JavaScript execute when a sub-grid receives focus?
I have a sub-grid that shows all Cases associated with an Account.
I would like to disable some fields on the form when the sub-grid receives focus.
RibbonDiffXML action for a ribbon button:
<Actions>
<JavaScriptFunction Library="$webresource:mda_convertemailtocaselib" FunctionName="ConvertEmailToCaseLib.addToCase">
<CrmParameter Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
</Actions>
This passes the sub-grid select items to a ribbon button, but I would like the JavaScript to execute before the ribbon button is pressed.
I haven't tried either of these out, but hopefully one of them should work for you.
Although it is a subgrid, there still is a control on the form. Unfortunately there is no "supported" way to know when a control gets focus since there aren't any OnFocus/OnBlur methods exposed via the CRM JS API. However you should be able to add your own JS event handler for that control and disabled the fields via the API Xrm.Page.getControl("fieldname").setDisabled(true)
I'm not 100% sure if this way would work, but it would be pretty sweet. Create a CustomRule EnableRule. In this CustomRule you call your own JS. In this create a function where you disable the fields and then return true to make the button enabled. It would look something like this:
function disableFieldsEnableRule() {
Xrm.Page.getControl().setDisabled(true);
...
...
return true; // so the button is enabled
}
The only reason I'm not sure if this will work is because I'm not sure if the Enable rules are checked each time you click on the subgrid or just the first time (I think it should be every time). Also I'm not sure if you want those fields re-enabled once you click off. If you do you might have to do something similar to this with a button on the native form, or something else.

Extension-Specific Context Menu

I'm trying to add an item to the right-click menu on my extension. I've tried to find a method which would work, but a lot of the results seem to deal with context menus on the actual page, not the extension icon itself. The contextMenus API doesn't seem to work for this, unfortunately.
There is currently no API for that. Head for Chromium Issue 78631 and click the star to cast your vote for it and receive updates by e-mail. In the meantime, you could create a popup with a menu that lists both the primary action and the actions you would have put in the context menu.
(I assume you're trying to add the context menu item to your browser action. Your question is a little ambiguous.)

Winforms c# outlook like Interface

I have already asked the same question but in regards with MDI Application design. Now just for R&D purpose so that we can go with 2 solutions to our user. Can somebody plz help me out...
We are developing an OutLook Style Application using C# Winforms. In that application we are using Microsoft Table Control. Which is what we need to show our UI. In the left hand pane we have menu and in the right hand we are displaying our UserControl. Like CustomerManager. This UserControl is doing Adding, Updating, Deleting ect etc but we want to put the common action buttons, Like Add,Delete,Save on the top toolbar.
So far so good, Now what we need to acheve is regardless of UserControl. What ever UserControl is loaded in the MainForm's TableControl. When the save button is clicked it should process the data on that UserControl. Obviously we will write the logic of the Save Action on each UserControl.
Please help...
Regards
Shanx
I may advice you the Krypton Toolkit. You will write an Outlook style app in seconds.
For all who ended up here like me in search of a free toolkit: As Vulkanino suggested to use Krypton, I loooked it up.
This is now open source Freeware and can be found unter: Krypton Toolkit
Create a Base user control that contains your Add, Delete, Save methods and events. Then create every other functional control that inherits from the Base control.
When you action the main toolbar buttons, you can safely cast each user control in your given container, to the Base user control.
Some MSDN links you might want to read up on:
http://msdn.microsoft.com/en-us/library/44a9ty12(VS.80).aspx
http://msdn.microsoft.com/en-us/library/ms173149(VS.80).aspx

Resources