Monday, March 28, 2016

Dynamically Create HTML table in Dashboard in MS CRM 2015/16

<html><head>
 <title>Test</title>
 <meta><meta><meta><meta><meta><meta><meta></head>
 <body style="word-wrap: break-word;">
 <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
 <script src="../WebResources/aac_sdk_jquery_1.9.1.min" type="text/javascript"></script>
 <script src="../WebResources/aac_SDK_REST" type="text/javascript"></script>
 <script src="../WebResources/aac_JavaScriptRESTDataOperations" type="text/javascript"></script>
<script type="text/javascript">
function getphonecall()
{
var currentUserID = Xrm.Page.context.getUserId();

if(currentUserID != null)
{

var serverUrl = Xrm.Page.context.getClientUrl();
//alert(serverUrl);

var oDataEndpointUrl = serverUrl +"/XrmServices/2011/OrganizationData.svc/";

oDataEndpointUrl+="PhoneCallSet?$select=StateCode,ActivityTypeCode,CreatedBy,Description,DirectionCode,ScheduledEnd,OwnerId,PhoneNumber,PriorityCode,RegardingObjectId,Subject";

var service = new ActiveXObject("MSXML2.XMLHTTP.3.0");

if(service != null)
{
service.open("Get",oDataEndpointUrl,false);
service.setRequestHeader("X-Requested-Width","XMLHttpRequest");
service.SetRequestHeader("Accept","application/json,text/javascript, */*");
service.send(null);
var requestResults = eval('('+service.responseText +')').d.results;
var tableData = "";
if(requestResults != null && requestResults.length >= 1)
{
for(var i = 0;i<requestResults.length;i++)
{
//var accountEntity = requestResults[i];
//alert(accountEntity.Subject);
 var service = requestResults[i].Subject;
  if (service != null) {
                        //dynamically add table data with Service Names
                        tableData = tableData + "<tr><td>" + service + "</td></tr>";

                    }
}
 var table = "<table style='font-family:Segoe UI;font-weight:normal;font-size:13px;'><tr style='height:20px'><td style='text-decoration:underline;'><b>Subject</b></td></tr>" + tableData + "</table>";
                //show table data on the Account form
                //window.document.writeln(table);
$("#dashboardContainer").append(table);
}
}
}
}

 </script>
 <style>
 h5 {
 font-family: Segoe UI,Tahoma,Arial;
 font-weight: bold;
 font-variant: normal;
 color: #000080;
 text-decoration: underline;
 }
 p {
 font-family: Segoe UI,Tahoma,Arial;
 font-size: 13px;
 }
 </style>
 <table>
 <tbody>
 <tr><td><p id="Phone call"></p><br></td></tr>
 <tr><td> <br></td></tr><tr>
 <td><button onclick="getphonecall()">Click here</button></td></tr>
 </tbody></table>
 <span id="refreshSpan">&nbsp;&nbsp;</span>
    <br>
    <span id="clientDropdown"></span>
    <br>
    <div id="dashboardContainer" style="width: 100%; white-space: nowrap;">
    </div>
 </body></html>

Hope this help!!

Monday, March 21, 2016

Adding fields to Quick Global Search Result in MS CRM 2015/16

With the Release of CRM 2015, one of the most exciting feature is Quick Find Search/Global Search/Universal Search. There are many blogs already existing to explore this functionality.

What I am going to tell you today is, how to change what you want to see in the search results? Yes, its true; you can change it as per your requirement. Following is a screenshot wise step by step process to achieve the same:
On the top navigation, locate to quick search and type text>>click enter (I am searching an account named ‘Movida’)
1
Currently, what you can see is Account Name, Account No. & Primary Contact
If you wish you to change it to Account Name, Account No. & Address 1:City; Go to settings>>Customization
2
Click on customize the system
Expand Entity & Go to Account>>View
4
Locate-Quick Find Active Accounts under views
5
Double click on Quick find view to modify it; the first three columns here are the fields which you see in the results of Global/Universal Search
6
So, if i wish to add Address 1: City. I will need to click on ‘Add view columns’and add my desired field here and with the help arrow keys visibl, i will bring it to either of 1st three positions.
Now, click ‘Save & Close’ and Publish customizations; you will now see the results you wanted.
Hope you find it helpful !

Transporting System Settings with Solutions

When you export a solution you are given the option to include various system settings to be transported with your solution and take effect in the target environment. This post provides some insights into what these system settings are and provides a list of the settings that are transported with the solution.


Upon solution export you are presented with the following dialog for exporting organization system settings:

image

However, the list above does not correspond exactly to the tabs of the system settings dialog:
image
So for example, if you want to transport the Date format with your solution, which of the above settings should you include in the solution? Is it even possible to transport all system settings with the solution? The following screenshots of all the system settings specify which system settings are included in which section of the solution export settings, and which ones are not transported at all. Here are the possible settings you can include and I’m using a color code to identify them later on:

image


Note that the red rectangle means that those system settings cannot be transported with a solution. So here are all the different sections of the system settings mapped according to the color codes above:

General
Calendar
Formats1
Formats2
Formats3
Formats4
Formats5
Auditing
Email
Marketing
Customization
Outlook
Reporting
Goals
AutoNumbering1
AutoNumbering2
AutoNumbering3
AutoNumbering4
AutoNumbering5
AutoNumbering6
AutoNumbering7

Hope it help!!

Sunday, March 13, 2016

Workflow Activity Input and Output Parameters and Data Types in MS CRM 2013/15/16

Microsoft Dynamics CRM supports two types of parameters for a workflow activity.

  • Input Parameters
  • Output Parameters

Input Parameters

The input parameter is annotated with the .NET attribute "Input".


DefaultAttribute

DefaultAttribute class can be used to specify a default value (using "Default" attribute) for an input parameter. 


Bool

[Input("Bool input")]
[Output("Bool output")]
[Default("True")]
public InOutArgument<bool> Bool { get; set; }


DateTime

[Input("DateTime input")]
[Output("DateTime output")]
[Default("2013-07-09T02:54:00Z")]
public InOutArgument<DateTime> DateTime { get; set; }


Decimal

[Input("Decimal input")]
[Output("Decimal output")]
[Default("20.75")]
public InOutArgument<decimal> Decimal { get; set; }


Double

[Input("Double input")]
[Output("Double output")]
[Default("200.2")]
public InOutArgument<double> Double { get; set; }


Integer

[Input("Int input")]
[Output("Int output")]
[Default("2322")]
public InOutArgument<int> Int { get; set; }


Money (Currency)

[Input("Money input")]
[Output("Money output")] 
[Default("232.3")]
public InOutArgument<Money> Money { get; set; }


OptionSetValue

[Input("OptionSetValue input")]
[Output("OptionSetValue output")]
[AttributeTarget("account", "industrycode")]
[Default("3")]
public InOutArgument<OptionSetValue> OptionSetValue { get; set; }
Attribute Target must specify the entity and attribute being referenced. 


String

[Input("String input")]
[Output("String output")]
[Default("string default")]
public InOutArgument<string> String { get; set; }


Entity Reference

[Input("EntityReference input")]
[Output("EntityReference output")]
[ReferenceTarget("account")]
[Default("3B036E3E-94F9-DE11-B508-00155DBA2902", "account")]
public InOutArgument<EntityReference> AccountReference { get; set; }
Reference Target attribute must specify the type of entity being referenced. 


Required Argument Attribute 

System.Activities.RequiredArgumentAttribute class can be used to specify that the input parameter is required.

[RequiredArgument]
[Input("Update next Anniversary date for")]
[ReferenceTarget("contact")]
public InArgument<EntityReference> Contact { get; set; }


Output Parameters

The output parameter is annotated with the .NET attribute "Output"

//this is the name of the parameter that will be returned back to the workflow
[Output("Credit Score")]
//this line identifies the specific attribute which will be passed back to the workflow
[AttributeTarget(CustomEntity, "new_creditscore")]
//this line declares the output parameter and declares the proper data type of the parameter being passed back.
public OutArgument<int> CreditScore {get;set;}

Refer to Microsoft documentation for more details

Option Set:

[Input("OptionSetValue input")]

[Output("OptionSetValue output")]

[AttributeTarget("account", "industrycode")]

[Default("3")]

public OutArgument<OptionSetValue> OptionSetValue { get; set; }

Output only:

[Output("OptionSetValue output")]

[AttributeTarget("account", "industrycode")]

public OutArgument<OptionSetValue> OptionSetVal { get; set; }

 To set:

this.OptionSetVal .Set(context, new OptionSetValue(intVar)); //change intVar var to yours


DateTime:

[Input("DateTime input")]

[Output("DateTime output")]

[Default("2004-07-09T02:54:00Z")]

public OutArgument<DateTime> DateTimeVal { get; set; }

Output only:

[Output("DateTime output")]

public OutArgument<DateTime> DateTimeVal{ get; set; }

 To set:

this.DateTimeVal.Set(context, myDateTimeValue); //change myDateTimeValue var to yours

Money:

[Output("Money output")]

public OutArgument<Money> MoneyVal { get; set; }

To set:

decimal decimalVar = 200.15; //change to your value

this.MoneyVal .Set(context, new Money(decimalVar)); //change decimalvar to yours


Lookup or Entity Reference:

[Output("EntityReference output")]
[ReferenceTarget("account")]  //change this to your Entity, for example if you want to lookup to entity Account
public OutArgument<EntityReference> EntityReferenceVal { get; set; }

To set:

Guid accountId = new Guid("6fd72744-3676-41d4-8003-ae4cde9ac282"); //change to your value

this.EntityReferenceVal.Set(context, new EntityReference("account", accountId)); //change the "account" and accountId to your variables (entity name and entity record id of the lookup)

Btw, we also can set default value like this:

[Output("Money output")]

[Default("232.3")]


public InOutArgument<Money> MoneyParameter { get; set; }

Hope it helps!


Thank you.

Saturday, March 12, 2016

Hide Posts From Social Pane in CRM 2013/2015/2016

In CRM 2013/15/16 Microsoft introduced the Social Pane, also known as Record Wall. Recently in our project we had a requirement to disable posts for a particular security role. To do that the first thing we did is to remove the Post Privileges for the security role. Please refer to the screenshot below.
screen 12
As you can see, remove all the privileges for the POST entity from the security role.
However after this change is made, when the user logs into the application, this is how it looks to the user.
screen 13
However what we needed to do is to hide the Posts tab altogether for this security role. A little bit of searching and found the below link. This gave us exactly what we needed.
All you need to do is call the method HidePosts() as mentioned in the link in the onload of the form and check for the currently logged in users security roles. And then hide the  post tab if the security role matches the condition.
Hope this helps!

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...