Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM


Leave a comment

Dynamcis 365 – Override Lookup view using Java script

Hi,

I have encountered some scenarios  in which I needed to override lookup view columns or apply some filters on the results depending on dynamics conditions at run time on CRM form.

In order to do that , add the following piece of code in the on load event

The following example filters results set no a specific case type

 

var viewId = “{00000000-0000-0000-0000-000000000001}”;

//add the entity name
var entityName = “incident”;

// add the view display name
var viewDisplayName = “Problem Cases”;

var fetchXml = “<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’false’>” +
“<entity name=’incident’>” +
” <attribute name=’title’ />” +
“<attribute name=’customerid’ />” +
“<attribute name=’incidentid’ />” +
“<order attribute=’title’ descending=’false’ />” +
“<filter type=’and’>” +
“<condition attribute=’bps_type’ operator=’eq’ value=’200000005′ />” +
” </filter>” +
” </entity>” +
“</fetch>”;

var layoutXml = “<grid name=’resultset’ object=’1′ jump=’productid’ select=’1′ icon=’1′ preview=’1′>” +
“<row name=’result’ id=’incidentid’>” +
“<cell name=’title’ width=’150′ />” +
“<cell name=’customerid’ width=’150′ />” +
“</row>” +
“</grid>”;

Xrm.Page.getControl(“parentcaseid”).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);


Leave a comment

Quick View Form and sub grid Issue in Dynamics 365

Hi,

Intro :

I encountered a problem while working with quick view forms having sub grids.

The quick view form is meant to display the account details upon selecting an account on lookup in custom entity form.

Problem:

Quick view form has sub grid displaying related record to account such as cases and opportunities , the problem occurs whenever you change the select account , all the details are updated to reflect the new selected account except the sub grids .

 They keep displaying the related records to the old one.

Fix :

  1. Add on change event handler on the account lookup
  2. Include the following piece of code in your java script function

var quickViewControl = Xrm.Page.ui.quickForms.get(“your quick view form name”);
if (quickViewControl != undefined) {
if (quickViewControl.isLoaded()) {
quickViewControl.refresh();
}
}


Leave a comment

Display Error , Warning , Info Notifications on form in CRM 2013/2015 Using Java Script

Notifications
Hi ,

Notifications were first introduced in CRM 2013 as a new feature in the java script SDK.

The following line of code shows to display notification

Xrm.Page.ui.setFormNotification(message, level , Id)

Message : Text to be displayed

Level : ERROR ,INFO , WARNING (Will specify Icon)

Id : Identify notification for clearing it later,

Info
Xrm.Page.ui.setFormNotification("INfo Message", "INFO", "Info1");

Error :
Xrm.Page.ui.setFormNotification("Error Message","ERROR", "Err1");

Warning :
Xrm.Page.ui.setFormNotification("Error Message","WARNING", "Warn1");

Clear notification by Id
Xrm.Page.ui.clearFormNotification("Err1");
Xrm.Page.ui.clearFormNotification("Info1");
Xrm.Page.ui.clearFormNotification("Warn1");


Leave a comment

How To : Get the Label Value for an OptionSet Using RetrieveAttribute Request in Microsoft Dynamis CRM 2011

The following code helps you to the get label of an option value.

Code:

private string GetCRMOptionSetLabel(IOrganizationService service, string entityname, string optionsetname, int value)
{
RetrieveAttributeRequest reqOptionSet = new RetrieveAttributeRequest();
reqOptionSet.EntityLogicalName = entityname;
reqOptionSet.LogicalName = optionsetname;
RetrieveAttributeResponse resp = (RetrieveAttributeResponse)service.Execute(reqOptionSet);
PicklistAttributeMetadata opdata = (PicklistAttributeMetadata)resp.AttributeMetadata;
var option = opdata.OptionSet.Options.FirstOrDefault(o => o.Value == value);
return option.Label.LocalizedLabels.FirstOrDefault().Label;

}


Leave a comment

How To : Retrieve the Marketing Lists Count Associated With Specific Campaign Activity in Microsoft Dynamics CRM 2011 Using JavaScript

Hi, in this article am gonna show how to retrieve Marketing Lists count associated with certain Campain Activity  in CRM 2011 Using JavaScript.

Code:

var command = new RemoteCommand(“MarketingAutomation”,”GetTargetListAssociated”);
var campaignActivityId = “xxxxx”;  // your campaign Activity ID
command.SetParameter(“campaignActivityId”, campaignActivityId);
var result = command.Execute();
var Marketinglistscount = result.ReturnValue;