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)

execute SCRIPT

(0) ShareShare
ReportReport
Posted on by

Hello everybody,

I have done a script of CRM 2015 and I want that it automatically runs when I upload the page where you can find this script.

I have tried to write at the end of the script a call to my function but this does not work.

CODE:

function cambiar(){
var valor = Xrm.Page.getAttribute("new_tipodeproyecto1").getValue();
switch(valor){

case 0:

Xrm.Page.ui.tabs.get("general").sections.get("Detalles").setVisible(true);
Xrm.Page.ui.tabs.get("general").sections.get("Participantes").setVisible(true);
break;

case 1:

Xrm.Page.ui.tabs.get("general").sections.get("Detalles").setVisible(true);
Xrm.Page.ui.tabs.get("general").sections.get("Participantes").setVisible(true);

break;

}

cambiar();

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    If I understand, you have script that you want to run when you open a form. If that's the case, you need to add an event to the Form Load event, which calls in to your javascript. Here are all the details: msdn.microsoft.com/.../gg334481.aspx

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Have you added that js file on the form ? if not then add it to the form

  • Community Member Profile Picture
    on at

    Hi Aiden, thanks for your answer.

    I have created my script, it name is: new_participantes_socios.

    I have added the script in the event on the form and in the Event Handlers i have added the script again putting on the name function: cambiar . But this does not work.

    How can i call in to my javaScript?

    Thanks again, i hope u can help me.

  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    The bottom call into your function isn't needed, you should just have the function there. When you configure the form load handler, you need to specify the Library and the Function. Your library will be "new_participantes_socios" and the function is "cambiar".

    Set this up, then comment out all the code in your method and add an alert to it. This is a simple way of seeing if your function is being called into. Once it is, you can add the rest of your code and troubleshoot that separate of the event hooks.

    Thanks!

     Aiden

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    You have 2 opening brackets and only one closing. Add one closing bracket } between closing bracket and call of cambiar function like:

    function cambiar() {
        var valor = Xrm.Page.getAttribute("new_tipodeproyecto1").getValue();
        switch (valor) {
    
            case 0:
    
                Xrm.Page.ui.tabs.get("general").sections.get("Detalles").setVisible(true);
                Xrm.Page.ui.tabs.get("general").sections.get("Participantes").setVisible(true);
                break;
    
            case 1:
    
                Xrm.Page.ui.tabs.get("general").sections.get("Detalles").setVisible(true);
                Xrm.Page.ui.tabs.get("general").sections.get("Participantes").setVisible(true);
    
                break;
    
        }
    }
    
    cambiar();


  • Community Member Profile Picture
    on at

    Ok, then i just need configure the form load handler with he library and  the function?

    With this changes the script have to runs automatically.

    So thank you for your time.

  • Community Member Profile Picture
    on at

    U have reason Andrii, i make a mistake when i have copied the code .

    Thanks you

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