I am trying to write js in a web resource to create a hotkey for activating the contact search field. So far I have this:
parent.document.onkeyup = function(e) {
var e = e || window.event;
if (e.altKey && e.which == 65) {
alert ('keyboard shortcut working!');
return false;
}
}
Above creates the hotkey, but I cannot find the ID for the search input field, and I suppose I'm unsure of how to call it in js as well.
Any help appreciated.
Regards,
Christine
*This post is locked for comments
Michel,
Yeah, I did that. But it still doesn't work everywhere.. I'm confused as to why though.
This is where I put it.
-Christine
Hey Christine,
Hi Michel,
I've been working on it for a while now and am having trouble making it available globally. I was thinking of adding the js web resource in the application ribbon, but I don't know where.. Any advice?? Hope your day's going well.
-Christine
Any time, Christine. Here to help :-)
Michel,
No jQuery, got it. I guess I will try to make the web resource available globally then. Thanks so much for all your help today. I appreciate you taking the time to explain some things to me!
-Christine
Hello Christine,
My guess would be that the javascript event gets unregistered or not loaded locally, because Dynamics loads and unloads pages in various levels of isolation, which may just cause your script to be unloaded.
Also, the focus of your keyboard is in different iframes at different times. It's not very noticeable but, the Dynamics user interface in the browser is built up out of many different iframes, unless you register your event hook in all of them, there will always be a chance that your current keyboard focus is in an iframe that doesn't have it.
.
As for using jQuery, which I assume you are trying to use, going by the famous $; please don't use that. You'll break some internal Dynamics scripts for sure, as they also use jQuery but, probably a different version you need/use. Stick to vanilla (plain, no frameworks) javascript in Dynamics.
Hi Michel,
Thanks for your speedy reply. I understand, and I appreciate your warning. As soon as I can get it working for my boss, I will look into other, supported options (kind of on a time crunch). That does work, however it only works once out of about every five attempts. Is there something I'm missing? It seems like once it calls the function, it won't do it again for a certain amount of time. I'm pretty new to programming in general, so I may be missing a fundamental part of knowledge to debug this. If you could help explain that phenomenon, I would appreciate it tons.
-Christine
EDIT: would the following work to resolve the problem mentioned above, and be supported?
$(document).on('pageinit', function(e)
rather than
parent.document.onkeyup = function(e)
Hello Christine,
What you are trying to do is an unsupported customization and will break the application in a future version.
I highly discourage you from implementing this type of customization.
.
That being said, the element you are looking for is called "ms-crm-FindButton"
You can trigger it to open by running this JS:
window.top.document.querySelector(".ms-crm-FindButton").click();
But... again... warning: this is an unsupported customization, if you break something, Microsoft will not help you fix it.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156