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. I wanted to put you the bit of note to be able to say thank you over again on the extraordinary thoughts you have contributed at this time. This has been remarkably generous of you to offer easily what numerous people might have distributed for an ebook in making some money for their own end, specifically considering the fact that you could have done it in case you wanted. These principles additionally worked as the fantastic way to be aware that other people have the identical dream really like mine to see way more with respect to this matter. I am sure there are lots of more enjoyable periods up front for individuals who start reading your blog.

  2. I’m extremely inspired with your writing skills as well as with the layout for your weblog.
    Is that this a paid topic or did you modify it your self?

    Either way stay up the nice high quality writing, it is
    rare to see a nice blog like this one today..

  3. Sandiego tv station KNSD stories () a-12-yearold Rhodesian ridgeback
    got herself caught around noon Saturday while having fun with youngsters at the college playground in Oceanside.

  4. I’m not that much of a internet reader to be honest but
    your sites really nice, keep it up! I’ll go ahead and bookmark
    your website to come back down the road. All the best

  5. First off I would like to say terrific blog! I had a quick question in which I’d like to ask if you do not mind.
    I was curious to find out how you center yourself and clear your head before writing.
    I’ve had trouble clearing my mind in getting my thoughts out.

    I do enjoy writing but it just seems like the first 10 to 15 minutes tend to be wasted
    just trying to figure out how to begin. Any suggestions or hints?
    Appreciate it!

  6. First off I would like to say fantastic blog!
    I had a quick question in which I’d like to ask if you do not mind.
    I was curious to find out how you center yourself and clear your
    head prior to writing. I have had a difficult time clearing my thoughts in getting my ideas out
    there. I truly do enjoy writing however it just seems like the first
    10 to 15 minutes are usually wasted simply just trying to figure out how to
    begin. Any suggestions or hints? Many thanks!

  7. An attention-grabbing discussion is value comment. I feel that it is best to write extra on this topic, it may not be a taboo subject however typically persons are not sufficient to speak on such topics. To the next. Cheers

  8. Spot on with this write-up, I really suppose this web site needs far more consideration. I抣l most likely be again to read far more, thanks for that info.

  9. My participation within the Operation Tackle That Bead Stash (I really have used only items in my stash) October challenge dedicated to Fireworks.

  10. Step one to selecting out the right Jewellery pendant is to slim down and select which mixture she is going to like
    higher. If the one you love wears extra silver and platinum jewelry it would be
    a good suggestion to go with the silver and yellow gold jewelry pendants.

  11. Thanks a lot for providing individuals with an extraordinarily marvellous possiblity to discover important secrets from this website. It can be very beneficial and as well , full of a great time for me personally and my office mates to visit your website really 3 times in one week to read through the latest guides you will have. Not to mention, I’m certainly satisfied considering the wonderful opinions you serve. Selected 1 points in this article are undoubtedly the most suitable I have had.

  12. The kinds and shapes of jewelry in historical Greece such because the armring
    (13th century BC), brooch (10th century BC) and pins (seventh century BC), have diversified extensively
    because the Bronze Age as properly. Other types of jewellery
    include wreaths, earrings, necklace and bracelets.

  13. There are some fascinating deadlines on this article however I don抰 know if I see all of them center to heart. There is some validity but I will take maintain opinion until I look into it further. Good article , thanks and we would like extra! Added to FeedBurner as nicely

  14. I really like your blog.. very nice colors & theme. Did you make this website
    yourself or did you hire someone to do it for you?
    Plz answer back as I’m looking to design my own blog and would like to find out where
    u got this from. thank you

  15. I do not know whether it’s just me or if everybody else encountering issues with your site.
    It appears as though some of the text in your
    posts are running off the screen. Can someone else please comment and let me know
    if this is happening to them as well? This could be a problem with my
    browser because I’ve had this happen before. Appreciate it

Leave a Reply

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