MSCRM 4.0 Web Service Toolkit (JavaScript)

 CRM Web Service Toolkit jest małą JavaScript’ową biblioteką umożliwiającą łatwy dostęp do web serwisów Microsoft Dynamics CRM 4.0.
Dzięki niej możemy w szybki sposób:

  • tworzć/aktualizować encje
  • zmieniać stan encji
  • tworzyć zapytania za pomocą fetchXML czy poprzez metodę RetrieveMultiple
  • i wiele innych metod dostępnych w web serwisach CRMa

Przykłady

Encje tworzymy za pomocą metody CrmServiceToolkit.Create()

[js]

// Use CrmServiceToolkit. Create() to create a CRM contact record.
var contact = new CrmServiceToolkit.BusinessEntity("contact");
contact.attributes["firstname"] = "Diane";
contact.attributes["lastname"] = "Morgan";
contact.attributes["gendercode"] = 2;
contact.attributes["familystatuscode"] = 1; // Picklist : Single – 1
contact.attributes["creditlimit"] = 3000;

var createResponse = CrmServiceToolkit.Create(contact);

[/js]

CrmServiceToolkit.Retrieve() używamy do zwracania pojedynczych encji

[js]
// Use CrmServiceToolkit.Retrieve() to retrieve a CRM contact record.
var contactId = ‘3210F2BC-1630-EB11-8AB1-0003AAA0123C’;
var cols = ["firstname", "lastname", "familystatuscode", "creditlimit", "birthdate", "donotemail"];
var retrievedContact = CrmServiceToolkit.Retrieve("contact", contactId, cols);

alert(retrievedContact.getValue(‘lastname’));
alert(retrievedContact.getValue(‘firstname’));
// Picklist value (integer)
alert(retrievedContact.getValue(‘familystatuscode’));
// Picklist selected text
alert(retrievedContact.getValue(‘familystatuscode’, ‘name’));
// Currency field value
alert(retrievedContact.getValue(‘creditlimit’));
// Currency field formatted value (string)
alert(retrievedContact.getValue(‘creditlimit’, ‘formattedvalue’));
// Datetime field date/time value
alert(retrievedContact.getValue(‘birthdate’));
// Datetime field date string
alert(retrievedContact.getValue(‘birthdate’, ‘date’));
// Datetime field time string
alert(retrievedContact.getValue(‘birthdate’, ‘time’));
// Bit field value
alert(retrievedContact.getValueAsBoolean(‘donotemail’));
[/js]

Metoda CrmServiceToolkit.setState() umożliwia nam zmiane stany encji

[js]
// Use CrmServiceToolkit.setState() to update a CRM record status.
var contactId = ‘3210F2BC-1630-EB11-8AB1-0003AAA0123C’;
var response = CrmServiceToolkit.setState(‘contact’, contactId, ‘Inactive’, 2);
alert(response);
[/js]

CrmServiceToolkit.queryByAttribute() zwraca nam wszystkie rekordy spełniające podane kryterja.

[js]
// Use CrmServiceToolkit.queryByAttribute() to retrieve all CRM records that match the query criteria.
var queryOptions = {
entityName : "contact",
attributes : ["firstname", "lastname"], // Search by firstname and lastname
values : ["John", "Smith"], // Find all contacts whose firstname is John, lastname is Smith
columnSet : ["familystatuscode", "creditlimit", "birthdate"],
orderby : ["creditlimit", "birthdate"]
};

var fetchedContacts = CrmServiceToolkit.queryByAttribute(queryOptions);
[/js]

Więcej informacji na:

http://crmtoolkit.codeplex.com/

http://danielcai.blogspot.com/2010/07/crm-web-service-toolkit-for-javascript.html

681 thoughts on “MSCRM 4.0 Web Service Toolkit (JavaScript)”

  1. Hey would you mind letting me know which webhost you’re using?
    I’ve loaded your blog in 3 different browsers and I
    must say this blog loads a lot quicker then most.

    Can you suggest a good internet hosting provider at a reasonable price?
    Many thanks, I appreciate it!

  2. I抎 need to check with you here. Which isn’t something I often do! I get pleasure from studying a put up that will make folks think. Also, thanks for permitting me to remark!

  3. What’s Going down i am new to this, I stumbled upon this I have
    discovered It positively useful and it has aided me out loads.
    I hope to give a contribution & help different users
    like its helped me. Great job.

  4. Attractive section of content. I just stumbled upon your site and in accession capital to assert that I get in fact
    enjoyed account your blog posts. Any way I’ll be subscribing to your feeds and even I achievement you access consistently rapidly.

  5. I feel this is among the most important info for me.
    And i am satisfied studying your article. But want to observation on few basic things, The site taste is
    ideal, the articles is in reality nice : D.

    Good activity, cheers

  6. Fantastic website you have here but I was wondering if you knew of
    any user discussion forums that cover the same topics discussed
    in this article? I’d really like to be a part of group where I can get feedback from
    other experienced people that share the same interest.
    If you have any suggestions, please let me know.

    Cheers!

  7. There are some attention-grabbing time limits on this article however I don抰 know if I see all of them center to heart. There may be some validity however I’ll take maintain opinion till I look into it further. Good article , thanks and we would like extra! Added to FeedBurner as effectively

  8. It is truly a nice and helpful piece of information. I’m happy that you simply shared this useful
    info with us. Please stay us up to date like this.
    Thank you for sharing.

  9. With havin so much written content do you ever run into
    any issues of plagorism or copyright violation? My blog has a lot of exclusive content I’ve either created myself or outsourced but it
    looks like a lot of it is popping it up all over the web without my authorization. Do you know any
    ways to help prevent content from being stolen? I’d really appreciate it.

  10. Amazing! This blog looks exactly like my old one! It’s on a
    totally different topic but it has pretty much the same layout and design. Outstanding choice of colors!

  11. Hiya! Quick question that’s completely off topic.
    Do you know how to make your site mobile friendly?
    My blog looks weird when viewing from my iphone.

    I’m trying to find a template or plugin that might be able to fix this problem.
    If you have any recommendations, please share. Appreciate it!

  12. Do you mind if I quote a few of your posts as long as I provide
    credit and sources back to your website? My website is
    in the very same area of interest as yours and my users would genuinely benefit from a lot of the information you present here.
    Please let me know if this alright with you. Regards!

  13. I am writing to let you be aware of of the useful encounter my wife’s princess found going through yuor web blog. She learned some things, not to mention what it’s like to have a wonderful helping nature to get folks easily fully grasp chosen advanced issues. You truly surpassed her desires. I appreciate you for displaying these practical, trustworthy, explanatory and as well as unique thoughts on this topic to Emily.

  14. Dating when you are over 30 can seem tough. We all had plans to be married by 26 right? Well, thanks to 30 Plus Dating, 30 is the new 20! So make this new years start with a bang

  15. whoah this weblog is fantastic i really like reading your articles.

    Stay up the great work! You realize, a lot of persons are
    looking round for this information, you could help them greatly.

  16. Thank you for every one of your efforts on this site. My mum really loves doing research and it is simple to grasp why. We notice all regarding the powerful means you provide sensible ideas on your web blog and as well welcome response from others on the theme and our princess has always been starting to learn so much. Enjoy the remaining portion of the year. You’re carrying out a superb job.

  17. There are some interesting time limits in this article however I don抰 know if I see all of them heart to heart. There’s some validity but I’ll take hold opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as effectively

  18. We’re a group of volunteers and opening a brand new scheme in our
    community. Your web site provided us with valuable information to focus on. You have done
    a remarkable job and our whole community will be grateful to you.

  19. I discovered your blog website on google and check a couple of of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Looking for forward to studying extra from you afterward!?

  20. I blog quite often and I really thank you for your content.

    Your article has truly peaked my interest. I’m going to bookmark your site and keep checking for new details about once a week.
    I opted in for your RSS feed as well.

  21. There are certainly a variety of details like that to take into consideration. That is a great point to deliver up. I provide the ideas above as common inspiration but clearly there are questions just like the one you convey up the place the most important thing will likely be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am certain that your job is clearly identified as a good game. Both boys and girls feel the impact of only a second抯 pleasure, for the rest of their lives.

  22. Nice post. I was checking constantly this blog and I’m impressed!
    Very helpful info particularly the last part 🙂 I care for such information much.
    I was seeking this particular info for a long time.

    Thank you and best of luck.

  23. Though facial boil time in the shower ought not to be searched by people that have cardio workout circumstances, as well raised British petroleum. Small kids moreover women that also need to reside of computer. Try taking some straight forward measures like for example

  24. Over the past 10, folks complement form and magnificence opt for water bathrooms. They furnish metabolic activity, your health perks the fact beat the very prospect together with the individual. A good solid water soak would be regarded common without as much annoyance of all exploring work out center or it may be health club. A new heavy steam shower room has solitude, closeness, and then privacy with regard to ultimate gratification.

Leave a Reply

Your email address will not be published. Required fields are marked *