Lock or Unlock Business process flow fields using JavaScript in CRM

Use the below syntax to lock or unlock the business process flow fields in a crm record using javascript,

Lock:

Xrm.Page.getControl(“header_process_FieldSchemaName”).setDisabled(true);

UnLock:

Xrm.Page.getControl(“header_process_FieldSchemaName”).setDisabled(false);

Advertisements

How to get list of all Entities Display Name, Logical Name and Other info using SQL Query in MSCRM?

Use the below query to get all the list of Entities Display Name, Logical Name and Object Type Code.

SELECT 
DISPLAYNAME.LABEL 'Display Name', 
EV.NAME 'Logical Name',
ObjectTypeCode 'Object Type Code'
FROM 
ENTITYVIEW EV INNER JOIN 
LOCALIZEDLABELLOGICALVIEW DISPLAYNAME
ON (EV.ENTITYID = DISPLAYNAME.OBJECTID) AND (DISPLAYNAME.OBJECTCOLUMNNAME = 'LOCALIZEDNAME')
WHERE 
LANGUAGEID = 1033 -- Add this if you want to filter records using language Id. For Example : LANGUAGEID 1033 is English
--AND ISCUSTOMENTITY = 1 -- Remove this if you want to show the system entities as well 
--AND ISACTIVITY = 0 -- Add this if you want to filter out the activity entity
--AND EN.NAME NOT LIKE '%MSDYN%' -- Add this if you want to remove like post album, filter, etc
ORDER BY 1

Output:

How to get list of all Entities Display Name, Logical Name and Other info using SQL Query in MSCRM

Inspired from Miss Dynamics CRM blog

How to get the number of Tables and their records information in MSCRM On-premise?

Follow the below steps to get the volume of Tables,

Step 1: Open MSCRM SQL Database.

Step 2: Under Databases, select the required <CRM_Org_Name>_MSCRM database. Right click on it and click on Reports -> Standard Reports -> Disk Usage by Table.

Disk Usage by Table

Step 3: Disk Usage by Table report will be displayed as shown below.

Disk Usage by Table Report

Other way to do the same is,

Step 1: Select the required MSCRM database. Click on F7 or View -> Object Explorer Details.

Disk Usage by Table - View Object Explorer Details

Step 2: Object Explorer will be opened in a new window. Right click on the header to select the required data columns to be displayed as shown below.

Disk Usage by Table - Object Explorer Details

Hope you got the results successfully :):):)

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 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 Install/ Uninstall Sample Data in CRM?

Follow the below steps to Install/ Uninstall Sample Data from Dynamics 365 CRM Online,

Step 1: Open Dynamics 365 Online. Goto Settings -> Data Management and click on Sample Data.

Sample Data Settings Under Data Management

Step 2: If you have not installed any Sample Data earlier, it will show Sample Data button. Click on it to import sample data given by CRM OOB.

Sample Data - Install Sample Data

Step 3: After clicking on it, Goto Imports under Data Management to see the Sample Data import records Status.

Sample Data - Imports Status

Step 4: Once all the records Status Reason change to Completed, we can Sample records in the Entities Specified in the Import Name.

For an Instance, below is the Contacts Sample Data imported during this operation,

Contacts Sample Data

Step 5: If you want to Uninstall the same data imported during this operation, Goto Settings -> Data Management and click on Sample Data.

Then click on Remove Sample Data button.

Remove Sample Data

Step 6: Records deletion status can be seen under Settings -> Data Management -> Bulk Record Deletion.

Bulk Record Deletion record Status

Hope you learned this feature in CRM :):):)