Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Hide webresource via Javascript error

(0) ShareShare
ReportReport
Posted on by

Hi 

I have following script:

function changevisibilitybutton() {

var ready = Xrm.Page.getAttribute("acc1_readytocreate").getValue();
if (ready.getValue() == 1)
{
Xrm.Page.getControl("WebResource_create").setVisible(true);
}
}
but getting following error:
Script Error
One of the scripts for this record has caused an error. For more details, download the log file.
ReferenceError: acc1_readytocreate is not defined at eval (eval at RunHandlerInternal (test444.crm11.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:24)
any ideas?
Thank you in advance
Decio

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Hide webresource via Javascript error

    Hi Shidin

    Thank you, changed code to use above method

    Decio

  • Verified answer
    Shidin Haridas Profile Picture
    3,497 on at
    RE: Hide webresource via Javascript error

    Great that your issue is resolved. You might also want to stop using 'Xrm.Page' methods, and instead start using the 'ExecutionContext.getFormContext ' instead.

    Happy D365'ing!

  • Community Member Profile Picture
    on at
    RE: Hide webresource via Javascript error

    removed parameter from handler properties and its now working, thank you

  • Aman Anvaria Profile Picture
    306 on at
    RE: Hide webresource via Javascript error

    Hi,

    var ready = Xrm.Page.getAttribute(acc1_readytocreate).getValue();

    Please write attribute name within double quotes.

    Thanks & Regards,

    Aman Anvaria

  • Community Member Profile Picture
    on at
    RE: Hide webresource via Javascript error

    still no luck.

    get same error:

    ReferenceError: acc1_readytocreate is not defined
    at eval (eval at RunHandlerInternal (test444.crm11.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:24)
    at RunHandlerInternal (test444.crm11.dynamics.com/.../ClientApiWrapper.aspx)
    at RunHandlers (test444.crm11.dynamics.com/.../ClientApiWrapper.aspx)
    at OnScriptTagLoaded (test444.crm11.dynamics.com/.../ClientApiWrapper.aspx)
    at test444.crm11.dynamics.com/.../ClientApiWrapper.aspx)

    3000.4.JPG0755.3.JPG4113.2.JPG3000.4.JPG

    the field in question is a two options one. Perhaps that's the issue

  • Aman Anvaria Profile Picture
    306 on at
    RE: Hide webresource via Javascript error

    Hi,

    Please try to run code provided by Goutam.

    If still facing any issue/error, please share.

    Thanks & Regards,

    Aman Anvaria

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Hide webresource via Javascript error

    Okay , could you please debug the code , may be you are missing something in attribute name or webresource name . The code looks perfect for me .

    And please share which line you are getting error.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Hide webresource via Javascript error

    Exactly this is the issue , you are using getValue() twice . 

    Try with this-

            function changevisibilitybutton() {
                var ready = Xrm.Page.getAttribute("acc1_readytocreate");
                if(ready!= null)
                {
                    if (ready.getValue() == 1)
                    {
                        Xrm.Page.getControl("WebResource_create").setVisible(true);
                    }
                }
            }


  • Community Member Profile Picture
    on at
    RE: Hide webresource via Javascript error

    Just realized I posted wrong code. Still same issue with following.

       function changevisibilitybutton() {

       var ready = Xrm.Page.getAttribute(acc1_readytocreate).getValue();

       if (ready == 1) {    

       Xrm.Page.getControl(WebResource_create).setVisible(true);

       }

       }

  • Aman Anvaria Profile Picture
    306 on at
    RE: Hide webresource via Javascript error

    Hi,

    Why are you using getValue twice?

    Thanks & Regards,

    Aman Anvaria

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans