Monday, 12 August 2019

Creating a full data set copy of your instance - Dynamics 365


Usually Microsoft asks the customers to do a copy of their instance to debug an issue. 

you need to follow the below mentioned steps.




Follow below steps for Copy of Instance:
1.       Browse to the Office 365 admin center and sign in using Office 365 Global administrator credentials.
2.       Click Admin centers > Dynamics 365.
3.       Choose the Instances tab.
4.       Select an instance, and then click Copy


Note: The org will be in “Administration Mode,” So please select the Support Instance click on Admin button and uncheck the Administration Mode check box

Retrieve records using Query Expression & C# SDK in CRM

Tested with CRM 2015

Let us see a simple example to retrieve records using Query Expression,
Task: Get a Contact record with the following values, where Full Name = Arun Potti
Retrieve Multiple - FetchXML SDK
Solution: Follow the below Steps,
Step 1: Include the below References in your project, you can get the same from Latest SDK.
Goto the path, SDK -> Bin for the dlls
Microsoft.Crm.Sdk.Proxy
Microsoft.Xrm.Sdk
Step 2: Include the below Framework Assemblies in your project,
Reference Manager - ConnectToCRM
Step 3: Add the below namespaces in your class file,
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Query;
Step 4: First we have to connect to CRM, for details Click Here
Step 5: User the below method to retrieve record, and it accepts the below parameters
Query Expression Retrieve Record Parameters
private static EntityCollection GetEntityCollection(IOrganizationService service, string entityName, string attributeName, string attributeValue, ColumnSet cols)
{
QueryExpression query = new QueryExpression
{
EntityName = entityName,
ColumnSet = cols,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression
{
AttributeName = attributeName,
Operator = ConditionOperator.Equal,
Values = { attributeValue }
}
}
}
};
return service.RetrieveMultiple(query);
}
Final usage of the function is as follows,
EntityCollection ec = GetEntityCollection(_service, "contact", "fullname", "Arun Potti", new ColumnSet("fullname", "parentcustomerid", "gendercode", "birthdate", "creditlimit", "donotsendmm"));
Step 6: Final Code is here,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Query;

namespace Retrieve_Record
{
class Program
{
static IOrganizationService _service;
static void Main(string[] args)
{
EntityCollection ec = null;
ConnectToMSCRM("arunpotti@XXXXXX.onmicrosoft.com", " XXXXXX", "https:// XXXXXX.api.crm5.dynamics.com/XRMServices/2011/Organization.svc");
Guid userid = ((WhoAmIResponse)_service.Execute(new WhoAmIRequest())).UserId;

if (userid == Guid.Empty) return; //Check for CRM Connection Establishment. If Not return, other wise will proceed to next step

ec = GetEntityCollection(_service, "contact", "fullname", "Arun Potti", new ColumnSet("fullname", "parentcustomerid", "gendercode", "birthdate", "creditlimit", "donotsendmm"));

if(ec.Entities.Count > 0) //Check for EntityCollection count
{
string output = string.Empty;
foreach (var item in ec.Entities)
{
//String
if (item.Attributes.Contains("fullname")) //Check for fullname value exists or not in Entity Collection
output += "Full Name : " + item.Attributes["fullname"] + "\n";

//Lookup
if (item.Attributes.Contains("parentcustomerid")) //Check for parentcustomerid exists or not in Entity Collection
output += "Company : " + ((EntityReference)item.Attributes["parentcustomerid"]).Name + "\n";

//OptionSet
if (item.Attributes.Contains("gendercode")) //Check for gendercode exists or not in Entity Collection
output += "Gender : Name - " + item.FormattedValues["gendercode"] + ", Value - " + ((OptionSetValue)item.Attributes["gendercode"]).Value + "\n";

//Date
if (item.Attributes.Contains("birthdate")) //Check for birthdate exists or not in Entity Collection
output += "Birthday : " + ((DateTime)item.Attributes["birthdate"]).ToLocalTime().ToShortDateString().ToString() + "\n";

//Currency
if (item.Attributes.Contains("creditlimit")) //Check for creditlimit exists or not in Entity Collection
output += "Credit Limit : " + ((Money)item.Attributes["creditlimit"]).Value + "\n";

//Two Options
if (item.Attributes.Contains("donotsendmm")) //Check for donotsendmm exists or not in Entity Collection
output += "Send Marketing Materials : Name - " + item.FormattedValues["donotsendmm"] + ", Value - " + ((Boolean)item.Attributes["donotsendmm"]).ToString();
}
Console.WriteLine(output);
Console.ReadKey();
}
}

private static void ConnectToMSCRM(string UserName, string Password, string SoapOrgServiceUri)
{
try
{
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = UserName;
credentials.UserName.Password = Password;
Uri serviceUri = new Uri(SoapOrgServiceUri);
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);
proxy.EnableProxyTypes();
_service = (IOrganizationService)proxy;
}
catch (Exception ex)
{
Console.WriteLine("Error while connecting to CRM " + ex.Message);
Console.ReadKey();
}
}

private static EntityCollection GetEntityCollection(IOrganizationService service, string entityName, string attributeName, string attributeValue, ColumnSet cols)
{
QueryExpression query = new QueryExpression
{
EntityName = entityName,
ColumnSet = cols,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression
{
AttributeName = attributeName,
Operator = ConditionOperator.Equal,
Values = { attributeValue }
}
}
}
};
return service.RetrieveMultiple(query);
}
}
}
Step 7:  You can see the below output,
Retrieve Multiple - FetchXML SDK Output

Thursday, 8 August 2019

Problem with assign a user to a team without the system administrator role

You can't assign a user a security role which has privileges you do not hold yourself.
You cannot add a user to a Team which has a security role which has privileges you do not hold yourself (because they will be able to act as if they have that role themselves)
If you could do either of these things you could potentially create a user and use it to gain access to things you should not have - an "elevation of privileges".
Check the Team you are trying to add the user to, and make sure you have that role, then this should be fine.
Also note as a matter of best practice you may want to only give roles to Teams which have the exact rights you need the Team to have - if the Team exists so that it can own Case records, don't give it any access to anything else. Then no-one can accidentally assign an Account, or Opportunity to this Team, and you won't have so many issues about adding users to it.

Power Apps Drag & Drop Kanban code sample

  Introduction: The Kanban Board App Developers at a software company use the Kanban board to show their progress on development tasks and b...