Category Archives: MS CRM 2011

Get Comment from user before de-activating entity record

Requirement : While deactivating account record, we need to get deactivation comments from user before deactivating account.

Solution: We can implement this requirement using different ways, in this post we are going to provide out of the box solution for this requirement. We can achieve this using dialog, if you are new to dialogs I suggest you to refer https://msdn.microsoft.com/en-us/library/gg509010.aspx first, where you can learn about dialogs and their component.

Idea here is hide the out of the box deactivate button for account entity and then design a dialog with prompt and response, we can ask user to enter comments and then we can update account entity description field (or you can setup your own custom field) with the comments, after that we can deactivate account record. Using following steps to design our dialog:

  • Navigate to Settings -> Processes and select New button through process command bar
  • Enter process name for example “Deactivate Account
  • Select category as “Dialog” and select Account under entity drop down
  • Click on Add Step and select Page from drop down to add a page in dialog

dialog1

  • Select line under page and again click on Add Step and add a Prompt and Response.
  • Click on Set Properties button and set properties like below :

dialog2

  • Click on Save and Close and select Page area and then add Update from Add Step dropdown, now we will update account record.
  • Click on Set Properties, Select description field in account form and select Look For like below and first click on Add and then on Ok, so that comment will store in description field.

dialog3

  • Now finally add Change Status step from Add Step dropdown and set status to Inactive
  • Our dialog steps should look like below:

dialog4

  • Activate our dialog using Activate button on dialog command bar

Testing Dialog:

To test our dialog, now simply navigate to Sales->Accounts and select and account and click on Start Dialog button under more commands (…), it will display our dialog name, select our dialog and click on Add, it will ask for comment like below:

dialog6

Click on Next button after entering comments and finish it, it will store out comment in account record and will activate account, and you check your account record under Inactive view.

We can simply hide our of the box deactivate button using RibbonWorkbench tool, you can refer our post, for how to hide system buttons.

HIMBAP | Need any help in Microsoft CRM 2015 Development Contact US !!

Leave a comment

Filed under MS CRM 2011, MS CRM 2013, MS CRM 2015, MS CRM 2015 Update 1

Relabeling Composite Control Fields

We can change display name of the entity fields easily by editing field display name property. But we can’t change fields label used in address composite controls. In this post we are demonstrating how to relabel composite control fields.

Requirement:Relabel city field in address composite control in account entity.

Note: You can’t change field logical name once it is created.

Solution: We can implement this requirement using Java Script. We have option to access composite control using Java Script, we can refer them using following way:

<composite control name>_compositionLinkControl_<constituent attribute name>

So if we want to refer any field which is used in the composite control, We can do like following, we are accessing city field here:

<composite control name>_compositionLinkControl_address1_city

To relabel the normal fields, we can use setLabel method. so we can use the same method to relabel city as well. let’s say we want to rename city field to “Distric”. We can use following code for that:

Xrm.Page.getControl(‘address1_composite_compositionLinkControl_address1_city’).setLabel(“District”);

Similarly we can refer other fields as well.You can refer composite control name from the respective entity form or you can also refer it here.

Using Code: To use this code we need to create Java Script web resource, where we can have below method. We need to call this method on Onload of the account entity form.

function RelableAddressControl()

{

Xrm.Page.getControl(‘address1_composite_compositionLinkControl_address1_city’).setLabel(“District”);

}

accountform

Now after publishing our changes, when we will open any account record we will see changes like below:

addressfield

HIMBAP | Need any help in Microsoft CRM 2015 Development Contact US !!

Leave a comment

Filed under MS CRM 2011, MS CRM 2013, MS CRM 2015, MS CRM 2015 Update 1

Creating html web resource to show image attached in Notes Part 2

In our previous post we explained how we can get image from notes using OData endpoints, in this post we are going to explain how we can create html web resource and use our java script method to get and display image. We need to implement two steps:

  •   Create html page
  •   Deploy html page and SDK.REST.js using web resource

Create html page

Create html page using any html editor, use following code for html page

<html lang=”en-us”><head>
<script src=”../ClientGlobalContext.js.aspx”></script>
<script type=”text/javascript” src=”SDK.REST.js”></script>
<script type=”text/javascript”>
//check if document is loaded or not
var imgControl = document.createElement(“IMG”);
//Check if documented loaded fully
document.onreadystatechange = function () {
if (document.readyState == “complete”) {
getnotesImages();
}
}
//this function is used to get image from notes
function getnotesImages()
{ //get regarding object id
var regardingObjectId=window.parent.Xrm.Page.data.entity.getId();
//assign notes entity name
var entitySchemaName=”Annotation”;
var odataQuery = “?$top=1&$select=AnnotationId,DocumentBody,MimeType&” +
“$filter=ObjectId/Id eq guid'” + regardingObjectId +
“‘ and IsDocument eq true and startswith(MimeType,’image/’) “;
//call retrieveMultipleRecords method in SDK.REST javascript script library
SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getnotesImagesCallback, function (error) { alert(error.message); }, function(){});
}
//process callbanck result
function getnotesImagesCallback(resultSet)
{
if (resultSet.length > 0) {
var mimeType = resultSet[0].MimeType;
var body = resultSet[0].DocumentBody;
imgControl.src=”data:” + mimeType + “;base64,” + body;
document.getElementById(‘imagediv’).appendChild(imgControl);
}
}
</script>
<meta charset=”utf-8″></head><body style=”zoom: 1;”>
<div style=”width: 100px;” id=”imagediv”></div>
</body></html>

Deploy html page and SDK.REST library using web resource

Using following steps to deploy html page and SDK.REST library in MS CRM.

  •       Navigate to Settings -> Customization-> Customize the System from top navigation bar
  •       Navigate to Components -> Web Resources-> New
  •       Fill details like following screen

saveimg

  • Click on browse button and select your html web resource.
  •        Click on Save and then Publish
  •        Navigate to Components -> Web Resources-> New
  •        Fill details like following screen

sdk.rest

  • Click on browse and select SDK.REST.js from MS CRM SDK

Note: Please refer previous post for SDK.REST.js location.

Now we can place our html web resource in the account entity form by navigating Insert  -> Web Resource options. Save your changes and then publish account entity form.

form

When you will try to open your account record you should be able to see attached images loaded into html web resource.

img

HIMBAP | Need any help in Microsoft CRM 2015 Contact US !!

2 Comments

Filed under MS CRM 2011, MS CRM 2013, MS CRM 2013 Web Resource, MS CRM 2015

Creating html web resource to show image attached in Notes Part 1

Microsoft Dynamics CRM 2013 introduced new entity image feature, so we can have one image attribute and can use that to store entity image. But we can have only one image attribute per entity. So in this article we are going to demonstrate how we can build an image slider using the java script.

Microsoft Dynamics CRM store all the notes and attachment in annotation entity. Most of the out of box entity used to have relationship with this entity, but while creating our custom entity we can specifically select if we want to associate our custom entity with notes or not using following option under Communication & Collaboration. Keep in mind once you enable this option, there is not supported way to disable this option, but if you are not sure, if you need notes or not at the time of your entity creation better to leave this option un-selected, so that you can select this option after sometime if required.

notesoption

Note: The default size for notes attachment is 5 MB but if required you can increase this limit up to 32 MB.

For our demo purpose we are going to use account entity which already have relationship with notes entity. We will utilize attachment feature to attach image and use that in our html web resource for display. So basically we are going to implement below steps

  •     Get entity image from notes
  •     Create and deploy html web resource.

Get entity image from notes

We can attach image in notes using social pane in Microsoft Dynamics CRM 2015, like following screen.

attachimage

Once image is attached to notes, we can retrieve it using OData or Soap endpoint, we are going to use OData endpoints in this article. To retrieve data from notes we need to query annotation entity based on ObjectId field, that we can get entity id using getId method. We need to write retrieve multiple call to get image record, we can use SDK.REST.js java script library that comes with MS CRM SDK and call it’s retrieveMultipleRecords method to get data based our query. Please download MS CRM SDK to get details about this library and it’s method.

function getnotesImages()
{ //get regarding object id
var regardingObjectId=window.parent.Xrm.Page.data.entity.getId();
//assign notes entity name
var entitySchemaName=”Annotation”;
var odataQuery = “?$top=1&$select=AnnotationId,DocumentBody,MimeType&” +
“$filter=ObjectId/Id eq guid'” + regardingObjectId +
“‘ and IsDocument eq true and startswith(MimeType,’image/’) “;
//call retrieveMultipleRecords method in SDK.REST javascript script library
SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getnotesImagesCallback, function (error) { alert(error.message); }, function(){});
}
//process callbanck result
function getnotesImagesCallback(resultSet)
{
if (resultSet.length > 0) {
var mimeType = resultSet[0].MimeType;
var body = resultSet[0].DocumentBody;
imgControl.src=”data:” + mimeType + “;base64,” + body;
document.getElementById(‘imagediv’).appendChild(imgControl);
}}

Note: You can download latest CRM SDK from here and find SDK.REST.js under SDK\SampleCode\JS\RESTEndpoint\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts.

Stay tuned for our next post to create and deploy html web resource using above method to get and display image.

HIMBAP | Need any help in Microsoft CRM 2015 Contact US !!

Leave a comment

Filed under MS CRM 2011, MS CRM 2013, MS CRM 2015

eBook Bonanza by Packt !!

Packt started eBook Bonanza from today until 6thJan 2015, customers will be able to buy any eBook or Video from the Packt website for just $5!

5-dollar-promo

Enjoy your reading !!

Leave a comment

Filed under MS CRM Book

Step by Step creating wildcard certificate

Most of the time while setting IFD for Microsoft Dynamics CRM 2011/2013 dev environment we use wildcard certificate. In this post we are going to provide step by step instruction to setup a wildcard certificate using IIS 7. We are using windows 2008 r2 operating system.

In order to create a wildcard certificate first we need to generate a certificate singing request using below steps

Step 1. Make sure certificate authority service up and running in your server (If certificate authority is not installed, you can refer this to install it)

Step 2.  Navigate to IIS manager and select your root server.

Step 3. Double click on Server Certificate under featured view.

rootserver

Step 4. Select “Create Certificate Request” under Actions from right hand section.

Step 5. Fill required information

himbapcert

 

Note: make sure to use an asterisk (*) because we are creating wildcard certificate.

Step 6. Click on Next and select below options

Cryptographic Service Provider: Microsoft RSA SChannel Cryptographic Provider

Bit Length: 2048

Step 7. Click next and specify file name for your certificate request for example (Let’s say wildcardcert)

Step 8. Click on Finish

Now we have created a certificate signing request, we can submit it against windows certificate authority using below steps.

Step 8. Run command prompt and use below command (you can right click on command prompt and run it as Administrator)

certreq-submit -attrib “CertificateTemplate: WebServer” c:\wildcardcert.txt    

first it will prompt to select certificate authority and then it will prompt to save your certificate, give it a name and save it. Exist from command prompt.

Now we will be completing our certificate request using complete certification request.

Step 9. Goto IIS->Root server->Server Certification->Actions and select Complete Request option under Action.

Step 10. Click on browse and select your certificate file that is created in last step.

Step 11. Provide friendly name and click ok.

Now our wildcard certificate is ready and can be used in binding MS CRM website.

HIMBAP | Need any help in MS CRM 2013 Contact US !!

1 Comment

Filed under IFD, MS CRM 2011, MS CRM 2013, Uncategorized

Adding Deployment Administrator in MS CRM Online

If you want to register custom business logic (plugin/custom workflow) in MS CRM, you should be part of the deployment admin group. In this post we are going to provide you information for adding user in Deployment Admin group in case of MS CRM Online.

If you are creating new user from Microsoft Office 365 Admin Portal you  can add user in “Global administrator” group, but if you want to add already created user in Global administrator group, you need to follow below instruction:

> Navigate to Microsoft Office 365 Admin Portal.

> Navigate to users and groups

> Select your user and Click on Edit user button

2014-07-22_17-06-04

 

> Click on Settings

> Select Global Admin from drop down and click on Save.

2014-07-22_17-09-59

 

HIMBAP | Need any help in MS CRM 2013 Contact US !!

 

Leave a comment

Filed under MS CRM 2011, MS CRM 2013

Update sub grids record in MS CRM

Did you get a requirement to update child entity records available in sub grid in parent entity, so for example if you are working opportunity and you need to update all the related quotes records which is available in quote sub grids under opportunity screen. You can use below code and can modify based on your requirement

function GetAllQuotesIds() {
var gridControl = document.getElementById(“opportunityQuotesGrid”).control; //Change grid name here
var subGrid = gridControl.get_allRecordIds();
for (i = 0; i < subGrid.length; i++) {
var Quote = new Object();
Quote.Name = “Demo”;    // change to update your field
var Id = subGrid[i].replace(“{“, “”).replace(“}”, “”);
UpdateQuotes(Id,Quote); } }

function UpdateQuotes(Id,Quote)
{
var jsonEntity = JSON.stringify(Quote);
var ODataPath = Xrm.Page.context.getServerUrl() + “/XrmServices/2011/OrganizationData.svc/QuoteSet”; //Change entity name here
$.ajax({ type: “POST”,
contentType: “application/json; charset=utf-8”,
datatype: “json”,
data: jsonEntity,
url: ODataPath + “(guid'” + Id + “‘)”,
beforeSend: function (XMLHttpRequest)
{XMLHttpRequest.setRequestHeader(“Accept”, “application/json”);
XMLHttpRequest.setRequestHeader(“X-HTTP-Method”, “MERGE”); },
success: function (data, textStatus, XmlHttpRequest) { alert(“Success”); },
error: function (XMLHttpRequest, textStatus, errorThrown) { alert(“Error while updating record” } }); }

Make sure you have REST and Jquery libraries are added to your form.

Hope it will help someone.

Enjoy !!!

Leave a comment

Filed under Ajax, MS CRM 2011, MS CRM 2013

Quick Tip for “Permission Denied” error in MS CRM

Are you getting “Permission Denied” error and you are confident that all your scripts are working fine and not causing this issue, you may be correct 🙂 it’s not always you will get this error because of your scripts only, you may get this error if you won’t add MS CRM url under trusted sites in your browser, so make sure to ask your clients to add MS CRM url in trusted site before using MS CRM application.

Hope it will help someone.

Enjoy !!!

Leave a comment

Filed under Ajax, MS CRM 2011, MS CRM 2013

Step By Step running On-demand workflow for all active records

Did you get a requirement to run your workflow for all active records ? if yes then this post going to help you to implement the same. OOB in MS CRM web client we can run our on-demand workflow only for 250 records, but there are some workaround to overcome this limitation, for example we could use MS CRM Outlook client, because in outlook client there is no limitation for number of records in per page. If you are using outlook client for MS CRM and interested in this workaround check this.
But if you are not use outlook client for MS CRM then you can use Workflow Execution Manager from MSCRM ToolKit. In this post we are going to provide step by step instruction how to use this tool.
So for implementing this requirement we need to follow three steps

  • Create a on- demand workflow for your requirement.
  • Get FetchXML query for your entity records.
  • Configure Workflow Execution Manager to run your workflow.

Create a on- demand workflow
Let’s create our on-demand workflow, in our example we are creating workflow on Account entity to set custom category as standard. So navigate to Settings->Process ->New and fill below details
Process Name:
Entity: Account
Category: Workflow

Click ok and add update step to set account category as “Standard” (click on Set Properties button to set account record category) . Save and Activate our workflow , after completion our workflow should look like below.
accountowkflow
Get FetchXML
Now navigate to Advance find and design your query and click on Download Fetch XML to get fetchxml query
advance find
Configure Workflow Execution Manager
Download MS CRM Toolkit from codeplex and extract it. Click on MSCRMToolKit.exe to start and follow below steps.

  • Select Connection Manager and fill below details

workfloeexutt

  • Test your connection and close connection manager dialog.

Start Workflow Execution Manger from Tool menu and follow below steps
Profile: Provide any name.
Source: Select your connection name.

Click on (Re) Load Workflow button to load your all on-demand workflows.
Paste your query in Records Query text field and Save your profile from File menu.
It should look like below
workflowexecution
Click on Execute workflow, it will start your workflow and will process all resultset based on query provided.

3 Comments

Filed under MS CRM 2011