Pages

Sunday, April 28, 2013

Dynamics CRM Application Navigation Using Site Map

The site map is xml included in a solution’s customizations file. Create a solution specifically for site map and application ribbon changes.
<SiteMap>
    <SiteMap>
        <Area>
            <Group>
                <SubArea/>
                    <Privilege/>
                </SubArea>   
            </Group>
        </Area>
    </SiteMap>
</SiteMap>

Use XML Notepad 2007 to edit XML

The default site map that you export does not include any of the following elements: Title, Titles, Description, or Descriptions.  Dynamics CRM doesn’t require these elements for the six default application areas, but they are required for new areas.  The Title, Titles, Description, and Descriptions elements apply to the Area, Group, and SubArea elements.

The Descriptions elements appear only in the Outlook client; the Titles elements appear in both the web and Outlook clients.

http://<crmserver>/<organizationname>/tools/solution/import/SolutionImportWizard.aspx.

Always export the latest site map and create a backup copy before making any edits.

Entity Display Areas


Thursday, April 25, 2013

CRM Feed Parse - JSON

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://<SERVER_NAME>/<ORG>/XRMServices/2011/OrganizationData.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">ContactSet</title>
  <id>http://<SERVER_NAME>/<ORG>/XRMServices/2011/OrganizationData.svc/ContactSet</id>
  <updated>2013-03-27T22:56:13Z</updated>
  <link rel="self" title="ContactSet" href="ContactSet" />
  <entry>
    <id>http://<SERVER_NAME>/<ORG>/XRMServices/2011/OrganizationData.svc/ContactSet(guid'a1034be1-0000-e211-a0c1-0050568c5ad0')</id>
    <title type="text">DAY NIGHT</title>
    <updated>2009-03-27T22:56:13Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Contact" href="ContactSet(guid'a1034be1-0000-e211-a0c1-0050568c5ad0')" />
    <category term="Microsoft.Crm.Sdk.Data.Services.Contact" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:FirstName>DAY</d:FirstName>
        <d:ContactId m:type="Edm.Guid">a1034be1-0000-e211-a0c1-0050568c5ad0</d:ContactId>
        <d:LastName>NIGHT</d:LastName>
      </m:properties>
    </content>
  </entry>
</feed>

Data Transfer From SQL Server to CRM 2011 using CozyRoc SSIS+

1)Open Sql Server Data Tools
2)Create New Integration Services Project
3)Right Click Connection Manager -> Select New Connection Manager
    Select OLEDB Type
    Select Exiting Data Connection or Create new connection
    Rename 'DNS_DB.conmgr' (DNS sql database connection)
   

Monday, April 22, 2013

Linq

For getting exact one instance it can be FirstOrDefault() method or SignleOrDefault() or just First() or Single().

The only difference is that methods without "OrDefault()" will throw an exception if enumeration will not satisfy their expectations, and methods with "OrDefault()" will just return null.

The dirrerence between Single and First is that Single expects exact one element in the collection and First expects at least one element.

How to get top 1 records from a query Just use FirstOrDefault() instead:

return (from a in dc.Applications
        where a.UserId == userId && a.chr_Version == version
        select a).FirstOrDefault<Application>();
SingleOrDefault() will throw an exception if there is more than one record, FirstOrDefault() will just take the first one.

Also you shouldn't have to cast to Application - your record already is of type Application.
For the first record you can try:
return (from a in dc.Applications where a.UserId == userId && a.chr_Version == version select a).FirstOrDefault();

For the first N use:
return (from a in dc.Applications where a.UserId == userId && a.chr_Version == version select a).Take(N);
Left Join SQL
select * from Employees e inner join States j on e.StateID = j.StateID left join Lookup c on (c.LookupValue = EmpTypeCode and c.LookupType ='TEMP') left join Lookup c1 on (c1.LookupValue = GovTypeCode and c1.LookupType ='PERM')

Linq
from el in db.Employees
join j in db.States on el.StateID equals j.StateID
join c1 in db.Lookup on new { etc = el.EmpTypeCode, ct1 = "TEMP" } equals new { etc = c1.LookupValue, ct1 = c1.LookupType }
into LeftJoinEmpLookup1 from c1 in LeftJoinEmpLookup1.DefaultIfEmpty()
join c2 in db.Lookup on new { gtc = el.GovTypeCode, ct2 = "PERM" } equals new { gtc = c2.LookupValue, ct2 = c2.LookupType }
into LeftJoinEmpLookup2 from c2 in LeftJoinEmpLookup2.DefaultIfEmpty()

Right Join SQL
select e.Name, d.Name from Employee e right join Department d on e.DeptID = d.ID
Linq
from dept in d
join employee in e on d.ID equals e.DeptID
into RightJoinDeptEmp from e in RightJoinDeptEmp.DefaultIfEmpty()

CRM Linq

//PickList values
private Dictionary<String, String> PickList(String entityName, String attID, string attName)
{
    Dictionary<String, String> dic = new Dictionary<String, String>();
    IOrganizationService service = (IOrganizationService)serviceProxy;
    QueryExpression qryExp = new QueryExpression(entityName);
    qryExp.ColumnSet = new ColumnSet(attName);
    EntityCollection entCollection = service.RetrieveMultiple(qryExp);
    dic = entCollection.Entities
        .Where(e => (e.Attributes.ContainsKey(attName)))
        .ToDictionary(e => e.Attributes[attID].ToString(), e => e.Attributes[attName].ToString());
    /*int i=1;
    foreach (var c in entCollection.Entities)
    {
        if (c.Attributes.ContainsKey(attName))
        {
        dic.Add(c.Attributes[attID].ToString(), c.Attributes[attName].ToString());
        }
    }*/
}

CRM Form Customization JavaScript



SAVE and Close Function
Save  -  Xrm.Page.data.entity.save();
Save &  Close  -  Xrm.Page.data.entity.save("saveandclose");
Save &  New  -  Xrm.Page.data.entity.save("saveandnew");
 Close - Xrm.Page.ui.close();

dns_JavaScript/Food.js
Read text box value

Xrm.Page.data.entity.attributes.get("dnsb_foodreason").getValue();
var fName = Xrm.Page.data.entity.attributes.get("fName").getValue();
check value is null or not
if (fName==null) fName = "";

Get html element value
var plFS = document.getElementById("dns_foodstatus");

Wednesday, April 17, 2013

XRM Data Transfer Error

Error 1
System.InvalidOperationException: Sequence contains no matching

Solution
PickList or OptionSet value is missing or Number  not matched

Error 2
System.Data.SqlClient.SqlException (0x80131904): Timeout expired.

Solution
Add DNS.dbml -> DNS.designer.cs -> DNSDataContext method
partial void OnCreated()
{
    //Set the timeout value to 300 = 50 Min.
    base.CommandTimeout = 3000;
}

CRM Plugin Code - Add/Update Entity, Connect WebService, Update Database

//Update Same Entity, Other entity, create new record in other entity  and connect to WebService
//Update to database  and
//Webservice update to database

using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;
using System.Xml;
using System.Net;
using GCEntity = CRMEnt.Entities;
using System.Text;
using System.ServiceModel;

CRM 2011/2013 Development Toolkit

http://msdn.microsoft.com/en-us/library/hh372957%28v=crm.6%29.aspx

With the Developer Toolkit, you can do the following:
  • Easily generate strongly typed proxy classes without having to run CrmSvcUtil.exe.
  • Generate plug-in code so you can immediately begin to write code for business logic.
  • Edit and register plug-ins without using the Plug-in registration tool.
  • Create new web resources or extract existing web resources, add them to your solution, edit them, and deploy changes all within Visual Studio.
  • Create and edit workflow and dialog processes from within Visual Studio.
  • Get easy access to entity and option set definitions, security role and field security profile information in Visual Studio.
Download SDK http://www.microsoft.com/en-us/download/details.aspx?id=40321