We provide end-to-end SharePoint and Dynamics 365 CRM solutions including installation, development, deployment, and configuration. Our expertise in SharePoint Online, SharePoint On-Premise, SPFx development, SharePoint Designer, PowerShell automation, Microsoft Flow (Power Automate), and Dynamics 365 CRM helps organizations streamline processes, improve customer engagement, and build secure, scalable digital workplace solutions.
Thursday, 21 September 2023
How to get other controls value in PCF Control
Wednesday, 20 September 2023
error 'context' is defined but never used no-unused-vars
When we run npm run build or npm start command and getting below error
[4:53:53 PM] [start] Initializing...
[4:53:53 PM] [start] Validating manifest...
[4:53:53 PM] [start] Validating control...
[4:53:55 PM] [start] Generating manifest types...
[4:53:55 PM] [start] Generating design types...
[4:53:55 PM] [start] Running ESLint...
[4:53:59 PM] [start] Failed:
[pcf-1065] [Error] ESLint validation error:
43:23 error 'context' is defined but never used no-unused-vars
Solution: Then ".eslintrc.json" file and add the below configuration under rules.
The OutputPath property is not set for project PCFPackage.cdsproj
When we run the below command in VS Developer command
"msbuild /t:build /restore" or "msbuild /p:configuration=Release"
and get the below error
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(780,5): error : The OutputPath property is not set for project 'PCFPackage.cdsproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\Users\user\Downloads\PCFPackage\PCFPackage.cdsproj]
Solution: Add below configuration in .cdsproj file
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Monday, 14 August 2023
Transaction in Dataverse using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=abcd@org.onmicrosoft.com;Password=password;Url=https://dorg.crm.dynamics.com;TokenCacheStorePath=c:\temp\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
// Create an ExecuteTransactionRequest object.
var requestToCreateRecords = new ExecuteTransactionRequest()
{
// Create an empty organization request collection.
Requests = new OrganizationRequestCollection(),
ReturnResponses = true
};
// Create several (local, in memory) entities in a collection.
var listData = new List<string>();
listData.Add("Account 1");
listData.Add("Account 2");
listData.Add("Account 3");
listData.Add("Account 4");
listData.Add("43b1e6dc-8e3a-ee11-bdf4-000d3a0aab51");
// Add a CreateRequest for each entity to the request collection.
foreach (var list in listData)
{
OrganizationRequest organizationRequest = new OrganizationRequest();
Entity accEntity;
accEntity = new Entity("account");
accEntity["name"] = list;
if (list == "43b1e6dc-8e3a-ee11-bdf4-000d3a0aab51")
{
organizationRequest.RequestName = "Update";
accEntity["name"] = "Update record";
accEntity.Id = new Guid("43b1e6dc-8e3a-ee11-bdf4-000d3a0aab51");
}
else
{
organizationRequest.RequestName = "Create";
}
organizationRequest.Parameters.Add("Target", accEntity);
requestToCreateRecords.Requests.Add(organizationRequest);
}
// Execute all the requests in the request collection using a single web method call.
try
{
var responseForCreateRecords =(ExecuteTransactionResponse)serviceClient.Execute(requestToCreateRecords);
// Display the results returned in the responses.
foreach (var responseItem in responseForCreateRecords.Responses)
{
if (responseItem != null)
{
if (responseItem.ResponseName == "Create")
{
Console.WriteLine(responseItem.ResponseName + " with account id as " + responseItem.Results["id"].ToString());
}
else if (responseItem.ResponseName == "Update")
{
Console.WriteLine(responseItem.ResponseName);
}
}
}
}
catch (FaultException<OrganizationServiceFault> ex)
{
Console.WriteLine("Create request failed for the account{0} and the reason being: {1}",
((ExecuteTransactionFault)(ex.Detail)).FaultedRequestIndex + 1, ex.Detail.Message);
throw;
}
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
Friday, 11 August 2023
Disassociate a record in dataverse using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
// Retrieve the accounts
var query = new QueryByAttribute("account")
{
ColumnSet = new ColumnSet("name")
};
query.AddAttributeValue("address1_city", "Redmond");
EntityCollection accounts = serviceClient.RetrieveMultiple(query);
//Convert the EntityCollection to a EntityReferenceCollection
var accountReferences = new EntityReferenceCollection();
accounts.Entities.ToList().ForEach(x => {
accountReferences.Add(x.ToEntityReference());
});
// The contact to associate to the accounts
var contacttoAssociateWithAccount = new EntityReference("contact",new Guid("edb87117-ce7e-ed11-81ab-000d3ac9cc70"));
// The relationship to use
var relationship = new Relationship("account_primary_contact");
// Use the Associate method
serviceClient.Disassociate(contacttoAssociateWithAccount.LogicalName, contacttoAssociateWithAccount.Id, relationship, accountReferences);
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
Associate a record in dataverse using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
// Retrieve the accounts
var query = new QueryByAttribute("account")
{
ColumnSet = new ColumnSet("name")
};
query.AddAttributeValue("address1_city", "Redmond");
EntityCollection accounts = serviceClient.RetrieveMultiple(query);
//Convert the EntityCollection to a EntityReferenceCollection
var accountReferences = new EntityReferenceCollection();
accounts.Entities.ToList().ForEach(x => {
accountReferences.Add(x.ToEntityReference());
});
// The contact to associate to the accounts
var contacttoAssociateWithAccount = new EntityReference("contact",new Guid("edb87117-ce7e-ed11-81ab-000d3ac9cc70"));
// The relationship to use
var relationship = new Relationship("account_primary_contact");
// Use the Associate method
serviceClient.Associate(contacttoAssociateWithAccount.LogicalName, contacttoAssociateWithAccount.Id, relationship, accountReferences);
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
Retrieve data from dataverse in paging using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
RetriveRecords(serviceClient);
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
private static void RetriveRecords(ServiceClient serviceClient)
{
int queryCount = 3;
int pageNumber = 1;
int recordCount = 0;
QueryExpression pagequery = convertFecthXMLToQueryExpression(serviceClient);
pagequery.PageInfo = new PagingInfo();
pagequery.PageInfo.Count = queryCount;
pagequery.PageInfo.PageNumber = pageNumber;
// The current paging cookie. When retrieving the first page,
// pagingCookie should be null.
pagequery.PageInfo.PagingCookie = null;
Console.WriteLine("Retrieving account records in pages...\n");
while (true)
{
// Retrieve the page.
EntityCollection results = serviceClient.RetrieveMultiple(pagequery);
if (results.Entities != null)
{
// Retrieve all records from the result set.
foreach (var acct in results.Entities)
{
Console.WriteLine("{0}.\t{1}", ++recordCount, acct["name"]);
}
}
// Check for more records, if it returns true.
if (results.MoreRecords)
{
Console.WriteLine("\n****************\nPage number {0}\n****************", pagequery.PageInfo.PageNumber);
// Increment the page number to retrieve the next page.
pagequery.PageInfo.PageNumber++;
// Set the paging cookie to the paging cookie returned from current results.
pagequery.PageInfo.PagingCookie = results.PagingCookie;
}
else
{
// If no more records are in the result nodes, exit the loop.
break;
}
}
}
private static QueryExpression convertFecthXMLToQueryExpression(ServiceClient serviceClient)
{
var query = @"<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/><attribute name='numberofemployees'/></entity></fetch>";
FetchXmlToQueryExpressionRequest fetchToQueryExpRequest = new FetchXmlToQueryExpressionRequest();
fetchToQueryExpRequest.FetchXml = query;
FetchXmlToQueryExpressionResponse fetchXmlToQueryExpressionResponse = (FetchXmlToQueryExpressionResponse)serviceClient.Execute(fetchToQueryExpRequest);
QueryExpression myquery = fetchXmlToQueryExpressionResponse.Query;
return myquery;
}
other way to fetch item using FetchXML in paging
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/org-service/page-large-result-sets-with-fetchxml
Thursday, 10 August 2023
Delete a record from Dataverse table using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
serviceClient.Delete("account", new Guid("a17f700a-6d37-ee11-bdf4-000d3a0aab51"));
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
RetrieveMultiple records from dataverse using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
var query = @"<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/><attribute name='numberofemployees'/></entity></fetch>";
var recordColl= serviceClient.RetrieveMultiple(new FetchExpression(query));
foreach (var accountrecord in recordColl.Entities)
{
Console.WriteLine(accountrecord.Id);
Console.WriteLine(accountrecord["name"]);
Console.WriteLine(accountrecord["numberofemployees"]);
}
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
retrieve a record from dataverse table using console application
public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
var columnSet = new ColumnSet("name","numberofemployees");
var accountrecord= serviceClient.Retrieve("account", new Guid("a17f700a-6d37-ee11-bdf4-000d3a0aab51"),columnSet);
Console.WriteLine(accountrecord.Id);
Console.WriteLine(accountrecord["name"]);
Console.WriteLine(accountrecord["numberofemployees"]);
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}