Hi, I would like to have that checkbox to be checked by default.
Unfortunately I have no clue where I can set this up
any help is appreciated.
Thanks in advance
Hi,
This is a known issue that is currently being addressed with a development fix.
Hi, is there an update on this case?
If this is really something that needs to work, there is an immediate option to custom code a fix into a custom .js file. That custom .js file would go into your wwwroot/js/custom folder so that it loads on every CRM page.
I've tested the below code wrapped in a crm.ready() function and it's working as expected. I'm using two methods to check the URL to test for the appropriate system action for intentional redundancy.
crm.ready(function () {
const Args = crm.getArgs(crm.url());
if (Args.Act != '2300' || window.location.href.indexOf("Act=2300") === -1) {
return;
}
var TASKS_BTN_ID = "view_tasks_btn";
var CHECKBOX_ID = "overdueTaskCheckBox";
function isTasksActive() {
var btn = document.getElementById(TASKS_BTN_ID);
if (!btn) return false;
return (
btn.getAttribute("tabindex") === "0" ||
btn.getAttribute("aria-pressed") === "true" ||
btn.classList.contains("k-selected")
);
}
function applyCheckboxWhenReady() {
var tries = 0;
var max = 40;
var t = setInterval(function () {
tries++;
var cb = document.getElementById(CHECKBOX_ID);
if (isTasksActive() && cb) {
if (!cb.checked) cb.click();
cb.checked = true;
cb.dispatchEvent(new Event("change", { bubbles: true }));
clearInterval(t);
}
if (tries >= max) clearInterval(t);
}, 50);
}
applyCheckboxWhenReady();
document.addEventListener("click", function (e) {
var btn = e.target && e.target.closest
? e.target.closest('button[data-group="views"]')
: null;
if (btn) applyCheckboxWhenReady();
}, true);
});
Hi Basil,
Thank you for the script!
I could successfully implement the script in a custom .js file.
There is one little adjustment I had to make.
As the script is looking for ACT=2300 in the URL it is only changing the value when logged into CRM already and having a URL with ACT=2300, SID etc.
What can happen:
If a user has set their default page to Calendar AND Tasks the URL isn't showing any SID or ACT Code. It's giving the URL "../eware.dll/go".
See updated version below:
crm.ready(function () {
const Args = crm.getArgs(crm.url());
if (Args.Act != '2300' &&
window.location.href.indexOf("Act=2300") === -1 &&
window.location.href.indexOf("/eware.dll/go") === -1) {
return;
}
var TASKS_BTN_ID = "view_tasks_btn";
var CHECKBOX_ID = "overdueTaskCheckBox";
function isTasksActive() {
var btn = document.getElementById(TASKS_BTN_ID);
if (!btn) return false;
return (
btn.getAttribute("tabindex") === "0" ||
btn.getAttribute("aria-pressed") === "true" ||
btn.classList.contains("k-selected")
);
}
function applyCheckboxWhenReady() {
var tries = 0;
var max = 50;
var t = setInterval(function () {
tries++;
var cb = document.getElementById(CHECKBOX_ID);
if (isTasksActive() && cb) {
if (!cb.checked) cb.click();
cb.checked = true;
cb.dispatchEvent(new Event("change", { bubbles: true }));
clearInterval(t);
}
if (tries >= max) clearInterval(t);
}, 100);
}
applyCheckboxWhenReady();
document.addEventListener("click", function (e) {
var btn = e.target && e.target.closest
? e.target.closest('button[data-group="views"]')
: null;
if (btn) applyCheckboxWhenReady();
}, true);
});Hi Basil,
Awesome - works great.
Thanks for the script.
There is one little adapation I made.
In case a user sets their start screen to Calendar/Tasks and Tasks screen no ACT=2300 ID is generated in the Browser URL, resulting in the script being executed only when changing pages and going back to calendar.
So, I just added in one line /eware.dll/go so this case is also working.
crm.ready(function () {
const Args = crm.getArgs(crm.url());
if (Args.Act != '2300' &&
window.location.href.indexOf("Act=2300") === -1 &&
window.location.href.indexOf("/eware.dll/go") === -1) {
return;
}
var TASKS_BTN_ID = "view_tasks_btn";
var CHECKBOX_ID = "overdueTaskCheckBox";
function isTasksActive() {
var btn = document.getElementById(TASKS_BTN_ID);
if (!btn) return false;
return (
btn.getAttribute("tabindex") === "0" ||
btn.getAttribute("aria-pressed") === "true" ||
btn.classList.contains("k-selected")
);
}
function applyCheckboxWhenReady() {
var tries = 0;
var max = 50;
var t = setInterval(function () {
tries++;
var cb = document.getElementById(CHECKBOX_ID);
if (isTasksActive() && cb) {
if (!cb.checked) cb.click();
cb.checked = true;
cb.dispatchEvent(new Event("change", { bubbles: true }));
clearInterval(t);
}
if (tries >= max) clearInterval(t);
}, 100);
}
applyCheckboxWhenReady();
document.addEventListener("click", function (e) {
var btn = e.target && e.target.closest
? e.target.closest('button[data-group="views"]')
: null;
if (btn) applyCheckboxWhenReady();
}, true);
});
That's the beauty of community participation. Even if I can get it 10% of the way there, sometimes that 10% is the hardest part to crack. I'm glad it helped! Way to tailor it (even minorly) to what you needed. Hopefully this will help others in a similar situation. Cheers!
*Community Hub is the new name for Sage City