Wednesday, 18 March 2015

JS Development in Dynamics CRM- Tips

    This post is regarding a javascript development tip which is very useful in Dyamics CRM. It was not my idea but my colleagues' (Irina and Alex). And it was an eye opener for me. As we all know we write js code on form load as well as on change event of different fields in Dynamics CRM. At a later point have you ever struggled to see on which fields we have js code ?  I have. Their suggestion was to use attach events by using the addonchange js function in Dynamics CRM. They also mentioned that this would make the js code more transparent. addonChange function is nothing but a js function to be called when the attribute changes. Please read the comments below. Thanks to Irina and Alex for this recommendation.


//Form Load
//onLoad function should be added to the Form load event of Form editor as usual
function onLoad() {

    FillData();// FillData Function call on Form load
    attachEvents();
}


//Function to attach events to different fields
function attachEvents() {

    //Attach Onchange event of lookup1(new_City) and lookup2(new_Profession)
    //You could attach as many fields as you prefer
    //Please note that the function name is passed as a parameter to addonchange function
    //Its the function we would like to call during onchange event of these fields.
    Xrm.Page.getAttribute("new_City").addOnChange(FillData);
    Xrm.Page.getAttribute("new_Profession").addOnChange(FillData);
    //No need to add FillData function call on the onchange event of each field on
    //the Form editor instead here we attach it using addOnChange function.
}

//Fill data based on lookup1 - new_City and lookup2 - new_Profession
function FillData() {

    //Js code to fill in the field based new_City and new_Profession
     //For instance you could fill another field using these 2 field values
}


20 comments:

  1. This is definitely one of the best articles I have read in this website! Thanks
    Microsoft Dynamics AX Training | Microsoft Dynamics CRM Online Training

    ReplyDelete
  2. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.

    SAP training in Chennai

    ReplyDelete
  3. Superb i really enjoyed very much with this article here. Really its a amazing article i had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your updation.
    Android training in chennai

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    online Python training
    python training in chennai

    ReplyDelete
  6. Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
    Best Devops training in sholinganallur
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram

    ReplyDelete
  7. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    angularjs Training in chennai

    angularjs-Training in pune

    angularjs-Training in chennai

    ReplyDelete
  8. Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
    microsoft azure training in bangalore
    rpa training in bangalore
    best rpa training in bangalore
    rpa online training

    ReplyDelete

  9. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you.
    Keep update more information..


    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training
    Selenium interview questions and answers

    ReplyDelete

  10. I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again.
    Deer Hunting Tips Camping Trips Guide DEER HUNTING TIPS travel touring tips

    ReplyDelete
  11. I must appreciate you for providing such a valuable content for us. This is one amazing piece of article. Helped a lot in increasing my knowledge.microsoft azure training in bangalore

    ReplyDelete
  12. Really it was an awesome article about JAVA, very interesting to read.You have provided an nice article,Thanks for sharing.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  13. Flvto is superb Reddit video downloader. It helps convert Reddit videos to mp3, and of course video file download includes audio track. Flvto Youtube Downloader Download

    ReplyDelete
  14. Also, the free download of Tally ERP 9 With Serial Key lets you keep track of banks and bank accounts, different debtors and creditors, and the .Tally 9 With Crack Full Version Zip

    ReplyDelete