hi ,
i have a code where i intend to show a ShowLoadingAlert , refresh the page and hide the alert after process finish
code is working fine in the first run however when i run it again it give me an error " TypeError: Cannot set property 'visibility' of undefined1 "
note : main method is SetExcuteOnSaveComplete
any support ? much appreciate
function ExecuteWhenSaveComplete(callback)
{
setTimeout(function ()
{
if (!Xrm.Page.data.entity.getIsDirty()) return callback();
//console.log('form not saved yet');
ExecuteWhenSaveComplete(callback);
}, 10000);
}
function SetExecuteOnSaveComplete()
{
alert("test")
showLoadingMessage("Loading...");
ExecuteWhenSaveComplete(function ()
{
console.log('form save complete');
HideLoadingMessage();
});
}
function showLoadingMessage(msg) {
try {
parent.document.getElementById('tdAreas').parentElement.style.display = 'none';
var newdiv = parent.document.createElement('div');
newdiv.setAttribute('id', 'msgDiv');
//newdiv.valign = 'middle';
newdiv.align = 'center';
newdiv.marginBottom = '5000px';
var divInnerHTML = "";
divInnerHTML += "";
divInnerHTML += "";
divInnerHTML += "";
divInnerHTML += "</br><img alt='' src='/_imgs/AdvFind/progress.gif' height='34px' width='34px'/></br>";
divInnerHTML += '<b>' + msg + '</b>';
divInnerHTML += "";
divInnerHTML += "";
newdiv.innerHTML = divInnerHTML;
newdiv.style.color = '#001D72 ';
newdiv.style.fontSize = '15px';
newdiv.style.zIndex = '1010';
newdiv.style.margin = '0 auto';
newdiv.style.marginTop = '210px';
newdiv.style.width = '300px';
newdiv.style.height = '135px';
newdiv.style.background = '#FFFFFF ';
newdiv.style.border = "thin solid #000000 ";
//newdiv.style.width = getBrowserWidth()+'px';
//newdiv.style.height = getBrowserHeight()+'px';
newdiv.style.position = 'relative';
parent.document.body.insertBefore(newdiv, parent.document.body.firstChild);
parent.document.getElementById('msgDiv').parentElement.style.visibility = 'visibile';
} catch (e) { alert(e) }
}
function HideLoadingMessage() {
try {
alert("LoadingHideMessage")
var msgdiv1 = parent.document.getElementById('msgDiv');
if(msgdiv1 != null && msgdiv1 != 'undefined')
{alert("msgdiv is not null")
parent.document.getElementById('tdAreas').parentElement.style.display = '';
parent.document.all.msgDiv.style.visibility = 'hidden';
}
} catch (e) { alert(e)}
}
*This post is locked for comments
i used this tools and there was no bug.send your new code of this tool...
use this new HideLoadingMessage function
function HideLoadingMessage() {
try {
var fieldElement = document.getElementById("msgDiv");
if (fieldElement!= null)
{
document.getElementById("msgDiv").style.visibility = "hidden";
}
else
{
parent.document.getElementById("msgDiv").style.visibility = "hidden";
}
parent.document.getElementById('tdAreas').parentElement.style.display = '';
} catch (e) { alert(e)}
}
Hi Hasooon,
That's interesting because I have been experiencing this as well on some entities. I think I got around the issue by placing the alert.js at the top of the js files list so it gets loaded in first. Web development can be a real pain.
it is working fine but sometimes it need an additional refresh in the beginning to start ! then it works fine how many times i would like ! is it a bug ?
actually this tools is not working i had to get another way and i did
alertjs file installed and added to library but when i trying to use does no sense ? any idea about
it was working as a first time but in the second run it doesn't
i found it where i had to relace ( msgdiv1.parentNode.removeChild(msgdiv1 ); ) instead of ( parent.document.all.msgDiv.style.visibility = 'hidden'; )
now it is working thanks for ur response thomas :)
Just taking a stab here, but is it because visible is spelled incorrectly?
parent.document.getElementById('msgDiv').parentElement.style.visibility = 'visibile';
Also have you tried debugging the code using F12 in the browser and placing breakpoints?
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