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

  • Community Member Profile Picture
    on at
    RE: execute SCRIPT

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

    Thanks you

  • Community Member Profile Picture
    on at
    RE: execute SCRIPT

    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.

  • Suggested answer
    a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: execute SCRIPT

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


  • Verified answer
    Aiden Kaskela Profile Picture
    19,694 on at
    RE: execute SCRIPT

    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

  • Community Member Profile Picture
    on at
    RE: execute SCRIPT

    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.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: execute SCRIPT

    Hi,

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

  • Suggested answer
    Aiden Kaskela Profile Picture
    19,694 on at
    RE: execute SCRIPT

    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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,880 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans