Windows Online Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 18 February 2009

Get Dynamic Entity Primary Attribute Guid Example

Posted on 04:33 by Unknown

Example by CrmSdk


public Guid GetDynamicEntityPrimaryAttributeGuid(DynamicEntity entity)
{
    if (entity != null)
    {
        string strPrimaryKeyAttributeName = entity.Name.ToLower() + "id";
        return ((Microsoft.Crm.Sdk.Key)entity.Properties[strPrimaryKeyAttributeName]).Value;
    }
    return Guid.Empty;
}

Example by Web Service

public Guid GetDynamicEntityPrimaryAttributeGuid(DynamicEntity entity)
{
    if (entity != null)
    {
        string strPrimaryKeyAttributeName = entity.Name.ToLower() + "id";
        for (int i = 0; i < entity.Properties.Length; i++)
        {
            if (entity.Properties[i].Name.ToLower() == strPrimaryKeyAttributeName)
            {
                KeyProperty property = (KeyProperty)entity.Properties[i];
                return property.Value.Value;
            }
        }
    }
    return Guid.Empty;
}
Read More
Posted in Dynamic Entity | No comments

Create Dynamic Entity Record Example

Posted on 03:19 by Unknown

StringProperty firstname = new StringProperty();
firstname.Name = "firstname";
firstname.Value = "Ranjit"; 

StringProperty lastname = new StringProperty();
lastname.Name = "lastname";
lastname.Value = "Singh"; 

// Create the DynamicEntity object.
DynamicEntity contactEntity = new DynamicEntity(); 

// Set the name of the entity type.
contactEntity.Name = EntityName.contact.ToString(); 

// Set the properties of the contact.
contactEntity.Properties = new Property[] {firstname, lastname}; 

// Create the target.
TargetCreateDynamic targetCreate = new TargetCreateDynamic();
targetCreate.Entity = contactEntity; 

// Create the request object.
CreateRequest create = new CreateRequest(); 

// Set the properties of the request object.
create.Target = targetCreate; 

// Execute the request.
CreateResponse created = (CreateResponse) service.Execute(create);
Read More
Posted in Dynamic Entity | No comments

Monday, 16 February 2009

Working with FetchXml()

Posted on 01:07 by Unknown

Fetch is a proprietary query language that is used in Microsoft Dynamics CRM. It is based on a schema that describes the capabilities of the language. The FetchXML language supports similar query capabilities as query expression. It is used primarily as a serialized form of query expression, used to save a query as a user owned saved view in the userquery entity or as an organization owned view in the savedquery entity. A FetchXML query can be executed by using the Fetch method. There are also messages to convert between query expression and FetchXML.

Generally, the RetrieveMultiple method performs faster than the Fetch method because it does not have to parse the query.

Microsoft Dynamics CRM 4.0 supports a new attribute on the link-entity node called visible. Setting visible to false will hide the linked entity in the advanced find user interface. It will still participate in the execution of the query and will return the appropriate results.

The following table lists the messages that work with the FetchXml language.

ExecuteFetch -> Executes a query.
FetchXmlToQueryExpression -> Converts from FetchXML to query expression.
QueryExpressionToFetchXml -> Converts from query expression to FetchXML.
ValidateSavedQuery -> Validates a saved query (view).

NOTE:
Notice that in either case, the privileges of the logged on user will affect the set of records returned. The Fetch method only retrieves records for which the logged on user has read access.

By default FetchXml returns MAX of 5000 records.

Read More
Posted in FetchXml | No comments

Dynamic Entity Add Attribute Helper Methods

Posted on 00:54 by Unknown
Examples: Calling the below methods:

string strDaysAttributeName = "cap_actualeffortdays";
string strHoursAttributeName = "cap_actualefforthours";
 
if (ObjProject.Properties.Contains(strDaysAttributeName))
    ((CrmNumber)ObjProject.Properties[strDaysAttributeName]).Value = iDays;
else
    CrmHelper.AddNumberProperty(ObjProject, strDaysAttributeName, iDays);

 
if (ObjProject.Properties.Contains(strHoursAttributeName))
    ((CrmNumber)ObjProject.Properties[strHoursAttributeName]).Value = iHours;
else
    CrmHelper.AddNumberProperty(ObjProject, strHoursAttributeName, iHours);


public static void AddStringProperty(DynamicEntity entity, string strColumnName, string DefaultValue)
{
    #region If Column attribute not in entity Collection 

        if (!entity.Properties.Contains(strColumnName))
        {
            StringProperty AttributeContactID = new StringProperty();
            AttributeContactID.Name = strColumnName;
            AttributeContactID.Value = DefaultValue;
        }
    #endregion If Column attribute not in entity Collection
}

 

public static void AddNumberProperty(DynamicEntity entity, string strColumnName, int DefaultValue)
{
    #region If Column attribute not in entity Collection 

        if (!entity.Properties.Contains(strColumnName))
        {
            CrmNumberProperty AttributeID = new CrmNumberProperty();
            AttributeID.Name = strColumnName;
            AttributeID.Value = new CrmNumber(DefaultValue);
        }
    #endregion If Column attribute not in entity Collection
}
Read More
Posted in Dynamic Entity | No comments

Update Dynamic Entity Record Example

Posted on 00:49 by Unknown

public static bool UpdateDynamicEntity(ICrmService Service, DynamicEntity entityName)
{
try
{
    // Create the update target.
    TargetUpdateDynamic updateDynamic = new TargetUpdateDynamic(); 

    // Set the properties of the target.
    updateDynamic.Entity = entityName; 

    //   Create the update request object.
    UpdateRequest update = new UpdateRequest(); 

    //   Set request properties.
    update.Target = updateDynamic; 

    //   Execute the request.
    UpdateResponse updated = (UpdateResponse)Service.Execute(update);

    return true;
}
catch (System.Web.Services.Protocols.SoapException ex)
{                
    return false;
}
catch (Exception ex)
{                
    return false;
}
}
Read More
Posted in Dynamic Entity | No comments

Retrieve Dynamic Entity Records Example

Posted on 00:25 by Unknown


DynamicEntity ObjProject = GetDynamicEntity(crmService, "new_timesheet", new Guid("{21CCFA77-FFF8-DD11-AE96-0003FFD751E0}"));


public static DynamicEntity GetDynamicEntity(ICrmService crmService, string strEntityName, Guid EntityGuid)
{
try
{
#region Retrieve Entity Record Dynamically
// Create the retrieve target.
TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic();
// Set the properties of the target.
targetRetrieve.EntityName = strEntityName;
targetRetrieve.EntityId = EntityGuid;


// Create the request object.
RetrieveRequest retrieve = new RetrieveRequest();


// Set the properties of the request object.
retrieve.Target = targetRetrieve;
retrieve.ColumnSet = new AllColumns();


// Indicate that the BusinessEntity should be retrieved as a DynamicEntity.
retrieve.ReturnDynamicEntities = true;


// Execute the request.
RetrieveResponse retrieved = (RetrieveResponse)crmService.Execute(retrieve);


// Extract the DynamicEntity from the request.
DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntity;
return entity;


#endregion
}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw new System.Exception(ex.Detail.InnerText);
}
catch (Exception ex)
{
throw new System.Exception(ex.Message);
}
}
Read More
Posted in Dynamic Entity | No comments

Sunday, 15 February 2009

Working with Dynamic Entity

Posted on 23:49 by Unknown

The DynamicEntity feature lets you generically access the data in any attribute on any entity in the system. In order to develop against the Microsoft CRM SDK, you must generate and consume a WSDL during code compilation. Because you must do this against a specific instance of the application, the only entities available are the core set included in the initial installation of Microsoft CRM. The WSDL does contain entity and attribute customizations but it is recommended that your code works with a clean installation. See Using the Microsoft CRM WebServices.


The DynamicEntity class is also used in plug-ins / callouts so that your callout code can work generically with any attribute on any entity without a re-compile.


The DynamicEntity class does not provide a name-base indexer, however, you can write your own. A simple approach to this problem is to loop through the dynamic entities property bag until you find the appropriate property.

Read More
Posted in Dynamic Entity | No comments
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Popular Posts

  • MS CRM 2011 Beta - Product Keys
    Here are the Product Keys for MS CRM 2011 Beta. The following product keys are available for this release: •Microsoft Dynamics CRM Workgroup...
  • Callout vs. Workflow
    You might find yourself wondering when you should use a pre- or post-callout versus when you should use a workflow rule. As you would expect...
  • Microsoft Dynamics CRM 2011 Release Candidate (RC) Announcement
    The Microsoft Dynamics CRM 2011 Release Candidate (RC) is now available for download from the Microsoft Download Center.  As with the Micros...
  • Declare Global Access Level functions in MS CRM Form.
    Global functions in MS CRM Form. The way CRM adds the javascript to the page, any function defined in the onload event will only have a loca...
  • How to remove the background color of XP Desktop Icon (in Wodows XP)
    In case you are wondering why your Windows XP Desktop Icons have a background, here is a quick guide to restore your transparent background ...
  • Say Hello to the World of Dynamics CRM 2011 Beta version
    Today, the Microsoft Dynamics CRM team has reached a key milestone as it releases the beta of Microsoft Dynamics CRM 2011, for both cloud-ba...
  • Install MS CRM 2011 Beta on Windows 2008 SP2 or Windows 2008 R2?
    I think everybody is consfuse when choosing the Operating System. So here are the facts: 1. You can choose either Windows 2008 SP2 or Window...
  • "Virtual Memory Low"
    “Your system is low on virtual memory” error message when you try to start an application.... Solution : Windows XP 1. Click Start , right-c...
  • Remove / Detach Email from Queue
    DetachFromQueueEmail Message Detaches the e-mail from the specified queue. // Use below code. // Rreplace the WebService URL service.Url = s...
  • Windows Washer v4.5 (Full) (for Windows XP only)
    Download

Categories

  • .NET
  • .NET String Methods
  • Adapters
  • Aggregate Functions
  • All Elements
  • Associated Records
  • Azure
  • BizTalk Adapter
  • Callouts
  • Child Pipeline
  • Crm 2011
  • Crm 2011 Beta
  • Crm 2011 Beta - Ribbons
  • Crm 2011 Beta Installation
  • CRM Online 2011
  • Customizations
  • Database
  • Debug
  • Deployment Service
  • Dynamic Entity
  • Email
  • FetchXml
  • FileSync
  • Form Assistant
  • Hide Button
  • IIS
  • Integration
  • Internet Connectivity
  • ISV
  • Java Script
  • Lead Capture
  • MS CRM
  • MS CRM 2011 RC
  • MS CRM 4 Roll Ups
  • MS CRM 5 Features
  • MS CRM Accelerators
  • MS CRM Entity Schema
  • MS CRM Global Variable and Functions
  • MS CRM Templates
  • Pivot Tables
  • Plugin Constructor
  • Plugins
  • Reports
  • s
  • Save Record
  • SDK
  • Sharepoint
  • Sharepoint 2010
  • Sharing Data Between Plug-ins
  • Social Networking
  • SSRS
  • Tabs
  • Tracing
  • Videos
  • Visual Studio 6
  • VPC
  • WampServer
  • Windows Service
  • Windows XP
  • Workflows
  • xRM

Blog Archive

  • ►  2013 (4)
    • ►  September (4)
  • ►  2012 (8)
    • ►  September (1)
    • ►  July (7)
  • ►  2011 (12)
    • ►  July (1)
    • ►  March (1)
    • ►  February (2)
    • ►  January (8)
  • ►  2010 (27)
    • ►  December (1)
    • ►  October (3)
    • ►  September (10)
    • ►  August (2)
    • ►  July (5)
    • ►  June (5)
    • ►  February (1)
  • ▼  2009 (41)
    • ►  December (1)
    • ►  November (5)
    • ►  August (3)
    • ►  July (2)
    • ►  June (3)
    • ►  May (9)
    • ►  April (2)
    • ►  March (5)
    • ▼  February (7)
      • Get Dynamic Entity Primary Attribute Guid Example
      • Create Dynamic Entity Record Example
      • Working with FetchXml()
      • Dynamic Entity Add Attribute Helper Methods
      • Update Dynamic Entity Record Example
      • Retrieve Dynamic Entity Records Example
      • Working with Dynamic Entity
    • ►  January (4)
  • ►  2008 (33)
    • ►  December (7)
    • ►  November (3)
    • ►  October (1)
    • ►  September (7)
    • ►  August (4)
    • ►  July (1)
    • ►  February (4)
    • ►  January (6)
  • ►  2007 (11)
    • ►  October (3)
    • ►  September (1)
    • ►  August (3)
    • ►  July (4)
Powered by Blogger.

About Me

Unknown
View my complete profile