web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JS web resource issue

(0) ShareShare
ReportReport
Posted on by 297

Hello Everyone !

Hope all are well. I wrote a JS web resource which execute on form load. But that does not execute not even first line of console.log() or debugger. I placed alert but alert just execute further not executing. Can anyone tell me how to resolve this issue?

Following is my code:


// a unique namespace for your libraries
var Sdk = window.Sdk || {};
(function () {
 
        // Code to run in the form OnLoad event
        this.changeStyle = function () {
            //alert("in margin padding");
            // Code of Switch Business Process Flow with another Business Process Flow
debugger;
   console.log("entered in margin padding script 1");
debugger;          

 //parent.document.getElementById("department_quickform_rfunsw_department_content").firstChild.style.marginTop = "-28px!important";
var firstChild = parent.document.getElementById("department_quickform_rfunsw_department_content").firstChild;
debugger;
firstChild.style.marginTop = "-28px !important";
debugger;
console.log("entered in margin padding script 2");
debugger;            parent.document.getElementById("department_quickform_rfunsw_department_content").firstChild.style.marginBottom = "-29px !important";
debugger;
 console.log("entered in margin padding script 3");
debugger;
            parent.document.getElementById("department_quickform_rfunsw_department_content").style.display = "none";
debugger;
 console.log("entered in margin padding script 4");
debugger;
    }

}).call(Sdk);

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    If the alert is fired then nothing wrong with the code or calling in form load.

    Try in different browser. Also open F12 developer toolbar & see the debugger; is hit or not?

    debugger and console.log works in developer console only, as you may aware.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    When you are defining the function inside namespace (Sdk ) then you should use JavaScript function name with name space while attach onload event . You should provide function name like "Sdk.changeStyle " instead of only "changeStyle ".

    formprop.png

    formprop.png

  • Microsoft Dynamics 365 Consultancy Profile Picture
    297 on at

    Now sicript executing but that element which i am getting by id is null so can you tell me whats wrong?

  • Microsoft Dynamics 365 Consultancy Profile Picture
    297 on at

    Now script executing but that element which i am getting by id is null so can you tell me whats wrong?

  • gdas Profile Picture
    50,091 Moderator on at

    what is your requirement , what you are trying to achieve can you please elaborate.

  • Microsoft Dynamics 365 Consultancy Profile Picture
    297 on at

    send-to-forum.PNG

    There is a quit up and down space from "SVH-St Vicent's Hospital - The Kirby Institute". I want to get this div and set margin top and margin bottom of it but when i get div so it is null. I am getting div by id.

  • Suggested answer
    KARTHIKGOWTHAM@SUYATITECH Profile Picture
    175 on at

    That seems to be an unsupported customization.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans