How to use XrmServiceToolKit JavaScript library?

Dear People,

Using XrmServiceToolKit Javascript library do a certain task like CRUD, Associate, Disassociate and Fetch efficiently and expeditiously via REST and SOAP.

Features

Extension methods for common operations.
Support for synchronous/asynchronous call
Support for all models of Microsoft CRM  (AD/IFD/CRM Online).
Lightweight and Simplicity – gives direct access to the Organization Data Service and Organization Service without having to generate SOAP request each time.

Common Functions

EnableField: A JavaScript Function to enable a CRM field
DisableField: A JavaScript Function to disable a CRM field
ShowField: A JavaScript Function to show a CRM field
HideField: A JavaScript Function to hide a CRM field
UpdateRequiredLevel: A JavaScript Function to update the required level a CRM field
GetObjectTypeCode: A JavaScript Function to get the object type code of a entity
CalculateDaysBetween: A JavaScript Function to calculate days between two dates
AddNotification: A JavaScript Function to add a CRM -like notification message on top of a form
ShowError: A JavaScript Function to show an alert of an error message
GuidsAreEqual: A JavaScript Function to check if two guilds are the same
DisableAllControlsInTab : A JavaScript Function to disable all controls in a tab by tab number
DisableAllControlsInSection : A JavaScript Function to disable all controls in a section label

Rest Functions

Create: A JavaScript Function to perform a create Rest Endpoint request
Retrieve: A JavaScript Function to perform a retrieve Rest Endpoint request
Update: A JavaScript Function to perform an update Rest Endpoint request
Delete: A JavaScript Function to perform a delete Rest Endpoint request
RetrieveMultiple: A JavaScript Function to perform a retrieveMultiple Rest Endpoint request
Associate: A JavaScript Function to perform an associate Rest Endpoint request
Disassociate: A JavaScript Function to perform a disassociate Rest Endpoint request

Soap Functions

Busines Entity: A JavaScript Object represents a business entity of CRM
Execute: A JavaScript Function to perform a execute soap request
Fetch: A JavaScript Function to perform a fetch soap request
Retrieve: A JavaScript Function to perform a retrieve soap request
RetrieveMultiple: A JavaScript Function to perform a retrieve multiple soap request
Create: A JavaScript Function to perform a create soap request
Update: A JavaScript Function to perform an update soap request
Delete: A JavaScript Function to perform a delete soap request
QueryByAttribute: A JavaScript Function to perform a query by attribute soap request
QueryAll: A JavaScript Function to perform a query all soap request to return all records (>5k+)
SetState: A JavaScript Function to perform a set state soap request
Associate: A JavaScript Function to perform an associate soap request
Assign: A JavaScript Function to perform an assign soap request
RetrievePrincipalAccess: A JavaScript Function to perform a retrieve principal access soap request
GrantAccess: A JavaScript Function to perform a grant access soap request
ModifyAccess: A JavaScript Function to perform a modify access soap request
RevokeAccess: A JavaScript Function to perform a revoke access soap request
GetCurrentUserId: A JavaScript Function to get the id of the current user
GetCurrentUserBusinessUnitId : A JavaScript Function to get the business unit id of the current user
GetCurrentUserRoles : A JavaScript Function to get the list of the current user roles
IsCurrentUserRole: A JavaScript Function to check if the current user has curtains roles
RetrieveAllEntitiesMetadata: A JavaScript Function to retrieve all entities’ metadata according to the expected EntityFilter
RetrieveEntityMetadata: A JavaScript Function to retrieve one entity’s metadata according to the expected entity name and EntityFilter
RetrieveAttributeMetadata: A JavaScript Function to retrieve one attribute’s metadata according to the entity name and attribute name

Extension Functions

JQueryXrmDependentOptionSet: Create Configurable Dependent Option Set to utilize CRM web resource.
JQueryXrmFieldTooltip: Create configurable tooltip for fields on CRM form
JQueryXrmCustomFilterView: Create configurable ability to add custom filter view to CRM lookup field on the form
JQueryXrmFormatNotesControl: Format the notes control to allow insert, allow edit

 

How to use XrmServiceToolkit with Dynamic CRM environment?

Download XrmServiceToolkit and add library with calls the methods files as shown in below screenshot XrmServicetoolkit dependency library JSON2, Jquery, and XrmServiceToolkit.

1

Dependency

JSON2 javascript library is required in CRM as a web resource to make the library working.

jQuery 1.7.2 above is required from version 1.3

Example:-

How to use XrmServiceToolKit Rest Retrieve?

function transpondernumber()
{

var EntityName, EntityId, LookupFieldObject;

var Name = "";

var resultXml;

LookupFieldObject = Xrm.Page.data.entity.attributes.get('transpondernumber');

if (LookupFieldObject.getValue() != null)

{

EntityId = LookupFieldObject.getValue()[0].id;

EntityName = LookupFieldObject.getValue()[0].entityType;

resultXml = getDetails(EntityName, EntityId);

if (resultXml != null && resultXml.attributes['capacityunitcost'] != null)

{

var unitCost = resultXml.attributes['capacityunitcost'].value;

Xrm.Page.getAttribute('capacityunitcostq').setValue(unitCost);

var capacity = resultXml.attributes['bandwidth'].value;

Xrm.Page.getAttribute('capacitybandwidth').setValue(capacity);

}

}

}

function getDetails(EntityName,EntityId)

{

var col =["capacityunitcost","bandwidth"];

var retrievedResult = XrmServiceToolkit.Soap.Retrieve(EntityName,EntityId,col);

return retrievedResult;

}
 How to use XrmServiceToolKit SOAP Fetch?
function getCapacityBandwidth() 
{
var fetchXml =
“<fetch mapping=’logical’>” +
“<entity name=’SatelliteLine’>” +
“<attribute name=’capacityunitcost’ />” +
“<attribute name=’bandwidth’ />” +
“</entity>” +
“</fetch>”;
// Execute the fetch
var capacitybandwidth = XrmServiceToolkit.Soap.Fetch(fetchXml);
// Get the results by loop through ‘bikes’
 for (var i = 0; i < capacitybandwidth.length; i++) 
 {
 //Statment
 }
}

 

Thanks!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s