Show Ribbon Buttons Only in Mobile Or Tablets in CRM

Configure the below Enable Rule for the required ribbon buttons to show Only in Mobile/ Tablets and not in CRM Web.

Show Or Hide Ribbon Buttons in Mobile or Tablets

Use the below function,

function ShowOrHideDeviceButtons() {
 var showOrHideFlag = false;
 // Form Factor = 2 - Tablet
 // Form Factor = 3 - Phone
 if (Xrm.Page.context.client.getClient() == "Mobile" && (Xrm.Page.context.client.getFormFactor() == 2 || Xrm.Page.context.client.getFormFactor() == 3)) {
 // Add code that should only run in CRM for phones here
 showOrHideFlag = true;
 }
 return showOrHideFlag;
}

Output:

Dynamics 365 for phones App View: Highlighted ribbon buttons can be seen only in Mobile/ Tablet.

Show Or Hide Ribbon Buttons in Mobile or Tablets in CRM App

CRM Web View: Buttons are not displayed in CRM Web View.

Show Or Hide Ribbon Buttons in Mobile or Tablets in CRM Web

Hope you learned a new thing today :):):)

 

How to delete a record in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to delete a record in Dynamics 365 Online V9.X using JavaScript,

Syntax:

Xrm.WebApi.deleteRecord(entityLogicalName, id).then(successCallback, errorCallback);

Parameters:

Name Type Required Description
entityLogicalName String Yes The entity logical name of the record you want to delete. For example: “account”.
id String Yes GUID of the entity record you want to delete.
successCallback Function No A function to call when a record is deleted. An object with the following properties will be passed to identify the deleted record:

·        entityType: String. The entity type of the record.·        id: String. GUID of the record.

·        name: String. Name of the record.

errorCallback Function No A function to call when the operation fails.

Return Value:
On success, returns a promise object containing the attributes specified earlier in the description of the successCallback parameter.

Example:
Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it on OnLoad of the Account Form.

After that, open an existing Account record.

function DeleteRecord() {
 // Delete Account record
 Xrm.WebApi.deleteRecord("account", "9C36DC38-79E9-E711-A95E-000D3AF27CC8").then(
 function success(result) {
 // Perform operations on record deletion
 Xrm.Utility.alertDialog("Account deleted", null);
 },
 function (error) {
 // Handle error conditions
 Xrm.Utility.alertDialog(error.message, null);
 });
}

Output:

Dynamics 365 Record Deletion V9.X

Hope you have successfully Deleted an Account record using New Syntax.

How to retrieve a record in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to retrieve a record in Dynamics 365 Online V9.X using JavaScript,

Syntax:

Xrm.WebApi.retrieveRecord(entityLogicalName, id, options).then(successCallback, errorCallback);

Parameters:

Name Type Required Description
entityLogicalName String Yes The entity logical name of the record you want to retrieve. For example: “account”.
id String Yes GUID of the entity record you want to retrieve.
options String No OData system query options, $select and $expand, to retrieve your data.

·        Use the $select system query option to limit the properties returned by including a comma-separated list of property names. This is an important performance best practice. If properties aren’t specified using $select, all properties will be returned.

·        Use the $expand system query option to control what data from related entities is returned. If you just include the name of the navigation property, you’ll receive all the properties for related records. You can limit the properties returned for related records using the $select system query option in parentheses after the navigation property name. Use this for both single-valued and collection-valued navigation properties.

You specify the query options starting with ?. You can also specify multiple query options by using & to separate the query options. For example:

?$select=name&$expand=primarycontactid($select=contactid,fullname)

See examples later in this topic to see how you can define the options parameter for various retrieve scenarios.

successCallback Function No A function to call when a record is retrieved. A JSON object with the retrieved properties and values will be passed to the function.
errorCallback Function No A function to call when the operation fails.

Return Value:
On success, returns a promise containing a JSON object with the retrieved attributes and their values.

Example:
Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it on OnLoad of the Account Form.

After that, open an Existing Account Record.

function RetrieveAccountRecord() {
 var accountRecordGuid = null, nextLine = "\n";
 accountRecordGuid = Xrm.Page.data.entity.getId();

if (accountRecordGuid != null && accountRecordGuid != "") {
 // Retrieve Record
 Xrm.WebApi.retrieveRecord("account", accountRecordGuid, "?$select=name,creditonhold,description,revenue,industrycode,_primarycontactid_value").then(
 function success(result) {
 // Perform operations on record retrieval
 var sampleValueText = "Retrieved values: ";

// Single Line of Text
 if (result.name != null) {
 sampleValueText += "Account Name : " + result.name + nextLine;
 }

// Two Option Set
 if (result.creditonhold != null) {
 sampleValueText += "CreditOnHold : " + result.creditonhold + nextLine;
 }

// Multiple Lines of Text
 if (result.description != null) {
 sampleValueText += "Description : " + result.description + nextLine;
 }

// Currency Field
 if (result.revenue != null) {
 sampleValueText += "Revenue : " + result.revenue + nextLine;
 sampleValueText += "Revenue (Formatted Text) : " + result['revenue@OData.Community.Display.V1.FormattedValue'] + nextLine;
 }

// Option Set
 if (result.industrycode != null) {
 sampleValueText += "Industry Text : " + result['industrycode@OData.Community.Display.V1.FormattedValue'] + nextLine;
 sampleValueText += "Industry Value : " + result.industrycode + nextLine;
 }

// Lookup
 if (result._primarycontactid_value != null) {
 sampleValueText += "Primary Contact GUID: " + result._primarycontactid_value + nextLine;
 sampleValueText += "Primary Contact Logical Name: " + result['_primarycontactid_value@Microsoft.Dynamics.CRM.lookuplogicalname'] + nextLine;
 sampleValueText += "Primary Contact Text: " + result['_primarycontactid_value@OData.Community.Display.V1.FormattedValue'] + nextLine;
 }

Xrm.Utility.alertDialog(sampleValueText, null);
 },
 function (error) {
 // handle error conditions
 Xrm.Utility.alertDialog("Error while retrieving the Account Record : " + error.message, null);
 }
 );
 }
}

Output:
Dynamics 365 Retrieve Record V9.X

Hope you have successfully retrieved Account record using New Syntax.

How to retrieve multiple records in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to retrieve multiple records in Dynamics 365 Online V9.X using JavaScript,

Syntax:

Xrm.WebApi.retrieveMultipleRecords(entityLogicalName, options, maxPageSize).then(successCallback, errorCallback);

Parameters:

Name Type Required Description
entityLogicalName String Yes The entity logical name of the records you want to retrieve. For example: “account”.
options String No OData system query options or FetchXML query to retrieve your data.

·        Following system query options are supported: $select, $top, $filter, $expand, and $orderby.

·        To specify a FetchXML query, use the fetchXml attribute to specify the query.

NOTE: You must always use the $select system query option to limit the properties returned for an entity record by including a comma-separated list of property names. This is an important performance best practice. If properties aren’t specified using $select, all properties will be returned.

You specify the query options starting with ?. You can also specify multiple system query options by using & to separate the query options.

See examples later in this topic to see how you can define the options parameter for various retrieve multiple scenarios.

maxPageSize Number No Specify a positive number that indicates the number of entity records to be returned per page. If you do not specify this parameter, the default value is passed as 5000.

If the number of records being retrieved is more than the specified maxPageSize value, nextLink attribute in the returned promise object will contain a link to retrieve the next set of entities.

successCallback Function No A function to call when entity records are retrived. An object with the following attributes is passed to the function:1

·        entities: An array of JSON objects, where each object represents the retrieved entity record containing attributes and their values as key: value pairs. The Id of the entity record is retrieved by default.

·        nextLink: String. If the number of records being retrieved is more than the value specified in the maxPageSize paramter, this attribute returns the URL to return next set of records.

errorCallback Function No A function to call when the operation fails.

Return Value:
On success, returns a promise that contains an array of JSON objects (entities) containing the retrieved entity records and the nextLink attribute (optional) with the URL pointing to next set of records in case paging (maxPageSize) is specified and the record count returned exceeds the paging value.

Example:
Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it on OnLoad of the Account Form.

After that, open an existing account record.

function RetrieveAllAccountRecords() {
 var outputText = "Account Name\t\t\tPhone\n---------------------------------------------------\n";
 Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name,telephone1").then(
 function success(result) {
 for (var accountRecordsCount = 0; accountRecordsCount < result.entities.length; accountRecordsCount++) {
 outputText += result.entities[accountRecordsCount].name + "\t\t" + result.entities[accountRecordsCount].telephone1 + "\n";
 }
 Xrm.Utility.alertDialog(outputText, null);
 },
 function (error) {
 // Handle error conditions
 Xrm.Utility.alertDialog(error.message, null);
 });
}

Output:

Dynamics 365 Retrieve All Records V9.X

Hope you have successfully retrieved all Account records using New Syntax.

How to update a record in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to update a record in Dynamics 365 Online V9.X using JavaScript,

Syntax:

Xrm.WebApi.updateRecord(entityLogicalName, id, data).then(successCallback, errorCallback);

Parameters:

Name Type Required Description
entityLogicalName String Yes The entity logical name of the record you want to update. For example: “account”.
id String Yes GUID of the entity record you want to update.
data Object Yes A JSON object containing key: value pairs, where key is the property of the entity and value is the value of the property you want to update.

See examples later in this topic to see how you can define the data object for various update scenarios.

successCallback Function No A function to call when a record is updated. An object with the following properties will be passed to identify the updated record:

·        entityType: String. The entity type of the updated record.

·        id: String. GUID of the updated record.

errorCallback Function No A function to call when the operation fails. An object with the following properties will be passed:

·        errorCode: Number. The error code.

·        message: String. An error message describing the issue.

Return Value:
On success, returns a promise object containing the attributes specified earlier in the description of the successCallback parameter.

Example:
Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it on OnLoad of the Account Form.

After that, open an existing Account record.

function UpdateAccountRecord() {
 // define the data to update a record
 var data =
 {
 "name": "Arun Potti Inc", // Single Line of Text
 "creditonhold": true, // Two Option Set
 "description": "This is the description of the sample account after update", // Multiple Lines of Text
 "revenue": 20000000, // Currency
 "industrycode": 2, // 2 - Agriculture and Non-petrol Natural Resource Extraction // OptionSet
 "primarycontactid@odata.bind": "/contacts(39582A13-E6E7-E711-A95E-000D3AF27CC8)" // ContactId - Arun Potti // Lookup
 }
 // Update the Account Record
 Xrm.WebApi.updateRecord("account", "9CCDEB5F-E9E7-E711-A95E-000D3AF27CC8", data).then(
 function success(result) {
 // Perform operations on record update
 Xrm.Utility.alertDialog("Account updated successfully", null);
 },
 function (error) {
 // Handle error conditions
 Xrm.Utility.alertDialog(error.message, null);
 }
 );
}

Output:
Dynamics 365 Update Record V9.X

Hope you have successfully updated a record using New Syntax.

How to create a record in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to create a record in Dynamics 365 Online V9.X using JavaScript,

Syntax:

Xrm.WebApi.createRecord(entityLogicalName, data).then(successCallback, errorCallback);

Parameters:

Name Type Required Description
entityLogicalName String Yes Logical name of the entity you want to create. For example: “account”.
data Object Yes A JSON object defining the attributes and values for the new entity record.

See examples later in this topic to see how you can define the data object for various create scenarios.

successCallback Function No A function to call when a record is created. An object with the following properties will be passed to identify the new record:

·        entityType: String. The entity logical name of the new record.

·        id: String. GUID of the new record.

errorCallback Function No A function to call when the operation fails. An object with the following properties will be passed:

·        errorCode: Number. The error code.

·        message: String. An error message describing the issue.

Return Value:
On success, returns a promise object containing the attributes specified earlier in the description of the successCallback parameter.

Example:
Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it OnLoad of the page of the Account.

After that, open any existing Account record

function CreateAccountRecord() {
 // Define the data to create new account
 var accountData =
 {
 "name": "Arun Potti Inc.", // Single Line of Text
 "creditonhold": false, // Two Option Set
 "description": "This is the description of the sample account", // Multiple Lines of Text
 "revenue": 10000000, // Currency
 "industrycode": 1, // 1 - Accounting // OptionSet
 "primarycontactid@odata.bind": "/contacts(39582A13-E6E7-E711-A95E-000D3AF27CC8)" // ContactId - Arun Potti // Lookup
 }

// Create account record
 Xrm.WebApi.createRecord("account", accountData).then(
 function success(result) {
 // Show Account GUID
 Xrm.Utility.alertDialog("Account created with ID: " + result.id, null);
 },
 function (error) {
 // Show Error
 Xrm.Utility.alertDialog("Error :" + error.message, null);
 }
 );
}

Output:

Dynamics 365 Record Creation V9.X

Hope you have successfully created a record using New Syntax.

How to Setup Dynamics 365 30 days Online Trial version?

Follow the below steps to Setup Dynamics 365 30 days Trial Version.

Step 1: Click here and open Dynamics 365 Trials. Click on Sign up here.

CRM Trials

Click on No, continue signing up.

Dynamics 365 Signup

Step 2: Give your Personal Information and click on Next.

Dynamics CRM 365 - Setup 1

Step 3: Create User Id and Password to login CRM 365 Trial. Click on Create my account.

Dynamics CRM 365 - Setup 2

Step 4: Select the Country Code and give your mobile number for verification. Click on Text me.

Dynamics CRM 365 - Setup 3

Step 5: Enter the OTP and click on Next.

Dynamics CRM 365 - Setup 4

Step 6: Please allow system for some time, a Trial Version will be created for your account. You can see the progress.

Dynamics CRM 365 - Setup 5Click on Set up.

Dynamics CRM 365 - Setup 6

Step 7: Select the required scenarios fits you best.

Am selecting None of these. Don’t customize my organization and click on Complete Setup.

Dynamics CRM 365 - Setup 7

Step 8: CRM Trial Organization will be ready with the selected scenarios/ none in few minutes.

Dynamics CRM 365 - Setup 8

Step 9: After Set up done, System will navigate to the CRM Trial Organization.

Dynamics CRM 365 - Setup 9

Step 10: As we see we don’t have any sample data on CRM Trial. Click here for my previous post and install Sample data in CRM.

Hope you successfully created CRM Trial and Installed Sample Data in CRM.

Enjoy by exploring CRM :):):)

Unified Service Desk 3.1 released

You can download Unified Service Desk 3.1 Version Package Deployer and Executables from the below links.

Name Size Download Link Description
Dynamics365-USD-3.1.0.882SELRES_01380cbd-d13c-4b96-b2e5-ed4ce4e4cdb5SELRES_ea96e7cb-0f15-4b21-b650-40aac942d8c7SELRES_0f0b31c4-d89b-4520-b52b-582c56bb05dbSELRES_f7f9037e-9b4c-48e6-b138-c292cc318d50SELRES_f7f9037e-9b4c-48e6-b138-c292cc318d50SELRES_0f0b31c4-d89b-4520-b52b-582c56bb05dbSELRES_ea96e7cb-0f15-4b21-b650-40aac942d8c7SELRES_01380cbd-d13c-4b96-b2e5-ed4ce4e4cdb5-PackageDeployer 87.0 MB Click here USD Package Deployer to install solution components in CRM
Dynamics365-USD-3.1.0.882-amd64 81.3 MB Click here 64 bit USD client
Dynamics365-USD-3.1.0.882-i386 81.3 MB Click here 32 bit USD Client

Click here to see “What’s new in Unified Service Desk 3.1