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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Aman Anvaria Profile Picture
    306 on at

    Hi,

    Why are you using getValue twice?

    Thanks & Regards,

    Aman Anvaria

  • Community Member Profile Picture
    on at

    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);

       }

       }

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

    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);
                    }
                }
            }


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

    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.

  • Aman Anvaria Profile Picture
    306 on at

    Hi,

    Please try to run code provided by Goutam.

    If still facing any issue/error, please share.

    Thanks & Regards,

    Aman Anvaria

  • Community Member Profile Picture
    on at

    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

    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

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

  • Verified answer
    Shidin Haridas Profile Picture
    3,499 on at

    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

    Hi Shidin

    Thank you, changed code to use above method

    Decio

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans