Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

what's XrmServiceToolkit

(0) ShareShare
ReportReport
Posted on by

Hi Team,

I sometimes see the following code, it's related to Dynamics CRM.

        var query = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">'
     + '<entity name="entity">'
     + '<attribute name="attributename" />'
     + '<attribute name="attributename" />'
     + '<attribute name="attributename" />'
     + '<order attribute="attributename" descending="false" />'
     + '<filter type="and">'
     + '<condition attribute="attributename" operator="ne" value="' + value + ' />'
     + '<condition attribute="attributename" operator="not-null" />'
     + '</filter>'
     + '</entity>'
     + '</fetch>';

        var results = XrmServiceToolkit.Soap.Fetch(query);


what is XrmServiceToolkit?  I am using Dynamics 365 online CRM V9.1.   I never find any info on D365 documentations,  it seems that this js uses SOAP instead of Web API.  Is it available in D365 CRM online V9.1?  

I only see there is Xrm.WebAPI,  but it's Async call,  is XrmServiceToolkit a Sync call?  Should i use it ?

thanks

  • Victor Onyebuchi Profile Picture
    410 on at
    RE: what's XrmServiceToolkit

    hello,If you're still facing the Async problem, wrap your code in the following if(formContext.ui.getFormType()=== 1 || formContext.ui.getFormType();=== 2){//put code here };

  • Community Member Profile Picture
    on at
    RE: what's XrmServiceToolkit

    hi , 

    thanks for your detailed info. but we're going to use Xrm.webAPI.  but we meet a new question:

    I am using Dynamics 365 CRM online V9.0. I am trying to add a custom filter on a lookup filed.  

    2744.1.png

    i write the following code: 

    var Sdk = window.Sdk || {};
    (function () {
    	this.addUnitLookupFilter = function (formContext) {
    		try {
    			var lookup_Values = '';
    			Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name&$filter=startswith(name,'A')").then(
    				function (results) {
    					for (var i = 0; i < results.entities.length; i++) {
    						var field_value = results.entities[i]["name"];
    						lookup_Values = lookup_Values + "<value>" + field_value + "</value>";
    					}
    
    					console.log(results);
    
    					if (lookup_Values != '') {
    
    						var fetchXml = '<filter type="and">' +
    							'<condition attribute="name" operator="in">' +
    							lookup_Values +
    							'</condition>' +
    							'</filter>';
    						formContext.getControl("parentaccountid").addCustomFilter(fetchXml);
    						console.log(fetchXml);
    					}
    				},
    				function (error) {
    					console.log("addUnitLookupFilter--err");
    				}
    			);
    
    		} catch (err) {
    			console.log(err);
    		}
    
    		console.log("addUnitLookupFilter--end");
    	}
    
    	// Code to run in the form OnLoad event
    	this.filterUnitLookupOnFormLoad = function (executionContext) {
    		var formContext = executionContext.getFormContext();
    
    		var parentControl = formContext.getControl("parentaccountid");
    
    		parentControl.addPreSearch(function () {
    			Sdk.addUnitLookupFilter(formContext);
    		});
    	}
    
    }).call(Sdk);

    in the code, I use Xrm.WebApi to retrieve data and then add it to the custom filter.  the code will run on form OnLoad event. 

    the problem is that  Xrm.WebApi is Async call, the function will immediately return before the request finished.  this causes the custom filter not work.  Can you advise some opinion? this troubles me a lot.

    thanks 

  • cloflyMao Profile Picture
    25,208 on at
    RE: what's XrmServiceToolkit

    Hi 10120,

    I just imported it (XrmServiceToolkit.js) to web resource and got error in a testing form in my D365 environment.

    22.PNG

    So WebAPI is your option. 

    Regards,

    Clofly

  • cloflyMao Profile Picture
    25,208 on at
    RE: what's XrmServiceToolkit

    Hi 10120,

    XrmServiceToolkit is a JavaScript library which can be used for JavaScript Development under the platform for Microsoft Dynamics CRM 2011/2013/2015 environments.

    https://archive.codeplex.com/?p=xrmservicetoolkit 

    https://blogs.msdn.microsoft.com/emeadcrmsupport/2016/07/04/dynamics-xrm-service-toolkit/   

    As the doc described, XrmServiceToolkit has not been updated for later higher version, but the doc not mentioned that it will not work on the latest versions of D365.

    From link1, both sync/async call are supported.

    55.PNG

    You could read doc below for how to use it:

    https://community.dynamics.com/365/b/dynamicspeople/archive/2016/12/20/how-to-use-xrmservicetoolkit-javascript-library 

    https://cdn.rawgit.com/XrmServiceToolkit/XrmServiceToolkit/feature/TypeScript/src/typedoc/index.html 

    My advice is that it is better to migrate to lastest Web API libraries. 

    Regards,

    Clofly

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: what's XrmServiceToolkit

    Hello ,

    XrmServiceToolkit is a library by which we used to make SOAP or REST call using JavaScript (internally uses organization service) before introduce Web API  in dynamics CRM. There is no XrmServiceToolkit available for V 9.1 as you know  Organization service has been deprecated in Dynamics 365 9.0 , even you can still use Organization Service using XMLHttpRequest but Microsoft recommended to use Web API or Xrm.WebAPI instead using Organization Service as this may be removed in future release.

    community.dynamics.com/.../311096

    Regarding synchronous call  in the client side also has  been  deprecated by most of browser due to performance overhead  , but you could always write your code inside onsuccess method of web API   or Xrm.WebAPI so that once result comes do your operation.

    Hope this helps.

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 Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard > Dynamics 365 general forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans