Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

JavaScript Alert : Microsoft Dynamics CRM (Cloud)

Posted on by 1,135

Hello Forum Members:

Does anybody have experience with developing custom Alerts, Microsoft Dynamics CRM (Cloud), with JavaScript? 

I know the JavaScript code to use to but don't know the easiest way to test custom page and alert.

Please help! Thanks!

  • rexkenley Profile Picture
    rexkenley 110 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Casey

    It would look something like this

    async function questions() {
      const q1 = await Xrm.Navigation.openConfirmDialog("q1");
      if (q1.confirmed) return; // if yes, we are done
      
      const q2 = await Xrm.Navigation.openConfirmDialog("q2");
      if (q2.confirmed) return; // if yes, we are done
    
      //so on and so forth
    }

    I envy you, there is no better time to learn JS.

    I wrote a little starter project to help those who want to write professional level JS for crm.

    https://github.com/rexkenley/d365js

    You can also tweet me questions @KentorThames.

    To learn the language itself, try these videos.

    https://www.youtube.com/watch?v=hdI2bqOjy3c

    https://www.youtube.com/watch?v=PMsVM7rjupU&list=PL6n9fhu94yhUA99nOsJkKXBqokT3MBK0b

    https://www.youtube.com/watch?v=PkZNo7MFNFg

    If you want advance JS

    https://github.com/getify/You-Dont-Know-JS

    Cheers!

  • CaseyB Profile Picture
    CaseyB 1,135 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Rex,

    So 2 goals for my learning here. First, I want to push my Custom Alert to do new things. For example, dialog box (alert) might say, does this answer your question, yes or no ? If answer is no, then a new Dialog Box (alert) will pop up with new questions. Second, I am very new with JavaScript. I took one class but the pace was took fast. I want to learn how to dig deeper into writing my own Javascript code. I can code HTML / CSS very well, but Javascript seems like algebra to me, it is hard to learn. Any suggestions? Do you of any forums or user groups? Thanks!

  • rexkenley Profile Picture
    rexkenley 110 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    That's a function that my form calls during the save event.

    You just basically follow the same pattern for any event where you want to control the dialog flow.

    async function nameOnChange() {
        await Xrm.Navigation.openAlertDialog("Name has changed");
        console.log("Alert Closed");
    }

    If you don't have the async and await, then console.log will NOT wait for the user to click on the alert box.

  • CaseyB Profile Picture
    CaseyB 1,135 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Rex,

    What does the formOnSave function do ? What process are you referring to ? Thanks!

  • rexkenley Profile Picture
    rexkenley 110 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Casey

    Have a look at the formOnSave function as an example

    github.com/.../account.form.js

  • CaseyB Profile Picture
    CaseyB 1,135 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Evgeniy,

    I was able to re-engineer and redo the all Customization Steps (i.e., Custom Account Form, Add Web Resource, and so on). The Custom Alert is up and running on my Microsoft Dynamics CRM Cloud again  this is great stuff with business process automation. Now at this point, I wish I could find a new consulting job, it is the dead of Winter  and I'm very hungry  Thanks again for everything... Casey (MCTS - Microsoft Dynamics CRM Applications)

      AlertDemoV3.jpg

  • CaseyB Profile Picture
    CaseyB 1,135 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Evgeniy,

    I was able to get my Custom Alert to work based on the '1' Value in integer field (on Alert Demo Tab).

    But I wanted to change the Alert message text IN MY JScript file. I added a new web resource and everything. Now my Custom Alert does not work anymore (no popup comes up at all). Should I delete everything and start again? My Custom Account Form is called AccountDev and that is where placed the Alert Demo (tab). Please help! Thanks!

  • CaseyB Profile Picture
    CaseyB 1,135 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Evgeniy,

    I was able to add a Tab, see below:

    AlertDemoTab.jpg

    Now I can continue, with my next steps along this journey of creating this Custom Alert with JScript 

    Thanks for your help so far!    

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Hey Casey,

    you got 2 options to go, when you add fields to a Form. You can either add an own Tab or a Section inside a Tab:

    pastedimage1578433371644v2.png

    For each of the scenarios you need to head over to "INSERT" in the navigation and then select what you would like to add. Actually it's pretty self explaining. Important thing to consider before you click on one of the options to create a new Tab or Section is to select a Tab. Note how the Summary tab on my Screenshot is highlighted with a blue border around it.

    If I add new Tab now, it will be inserted directly under the Summary Tab. If I add a new section, it will appear all the way at the bottom inside the Summary tab.

    Once you got one of the two things added, you can drag your field inside it

  • CaseyB Profile Picture
    CaseyB 1,135 on at
    RE: JavaScript Alert : Microsoft Dynamics CRM (Cloud)

    Evgeniy,

    I was able to create a copy of Account Form, which I called 'AccountDev'. The new AccountDev Form state says Unmanaged. I also created a custom integer field.

    I am having trouble adding a new 'Alert Demo' section that contains the custom field, as I don't how insert the section or area to the Body of AccountDev Form (above Summary). Do I add a Quick View Form called Alert Demo ?

    Please help!

    Thanks,

    Casey          

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,946 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,420 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans