locked
How use XRM Service Tollkit RRS feed

  • Question

  • i have used Daniel Cai's "CRM ServiceTollkit" in which i copy file that is "CRM Service Tollkit" to the end of any script and used some fuctions(Retrieve,Retrieve multiple,delete,update) that code i put in the main function....

    but there is another tollkit for CRM 2011 Xrm Service Tollkit by Jaimie Ji. any one use it and tell me example of how to retrive the entity recrod i downloade the toolkit and where past this file.........


    Muhammad Sohail



    • Edited by sohail450 Monday, June 25, 2012 12:38 PM
    Monday, June 25, 2012 12:36 PM

All replies

  • For CRM 2011, I am currently using Daniel Cai's XrmSvcToolkit and here are some sample codes for fetch and update.

    Fetch

    var fetchXmlQuery = "<fetch mapping='logical' aggregate='true' version='1.0'>" +
    							"<entity name='listmember'>" +
    								"<attribute name='listmemberid' aggregate='count' alias='recordcount' />" +
    								"<link-entity name='list' from='listid' to='listid'>" +
    									"<link-entity name='campaignitem' from='entityid' to='listid'>" +
    										"<filter>" +
    											"<condition attribute='campaignid' operator='eq' value='" + Xrm.Page.data.entity.getId().replace("{", "").replace("}", "") + "' />" +
    										"</filter>" +
    									"</link-entity>" +
    								"</link-entity>" +
    							"</entity>" +
    						"</fetch>";
    
    XrmSvcToolkit.fetch({
        fetchXml: fetchXmlQuery,
        async: false,
        successCallback: function (result)
        {
           alert("Record Count : " + result.entities[0].recordcount);
        },
        errorCallback: function (error)
        {
           alert("There was an error while fetching the data. Error: " + error.message);
        }
    });

    Update

    var TestID = Xrm.Page.getAttribute("new_testid").getValue()[0].id;
    var foo = {
        new_name: "Joo 4",
        new_TestNumber: 500
    };
    
    XrmSvcToolkit.updateRecord({
        entityName: "new_test",
        id: TestID,
        entity: foo,
        async: false,
        successCallback: function (result) {
           alert("Successfully Updated!");
        },
        errorCallback: function (error) {
           alert("There was an error when updating the record");
        }
    });

    Tuesday, June 26, 2012 10:33 AM