Get Related Entities

Example to get the list of emails associated to the Contact :

entity is the Contact entity
RelationShipName : Contact_Emails

public static IEnumerable GetRelatedEntitiesExtended(OrganizationServiceContext ctx, Entity entity, RelationShipName
relationshipShemaName) where T : Entity
ctx.MergeOption = MergeOption.NoTracking;
ctx.LoadProperty(entity, new Relationship(relationshipShemaName.ToString()));
//Microsoft.Xrm.Client for SKD 2015
return entity.GetRelatedEntities(relationshipShemaName.ToString());


SSIS Project with OLE DB Source and Kingwaysoft Destination

In this project we will create a project SSIS that will update a 10 field of entity, so i added a Data flow that contains an OleDB SOURCE that contains a sql query and a KingwaySoft destination that will update the 10 fields.
the DataFlow of the package :

the OleDB source Contains the sql query,the sql query will count the total of the 10 field

and finally the kingwaysoft destination mapped the fields

Convert TextBox field to Button with javascript

Hi, we can add a button to a solution crm with The Ribbon Workbench ribbonworkbench , Or we can convert a textBox Filed to button ,
So I create a filed type text and i added a code with javascript to change this field to button.
txtbox convert to button Dynamics crm 2013
this is the code of the custum button :

function ajoutButton(new_convertir) {
if (document.getElementById(new_convertir) != null) {
var sFieldID = "field" + new_convertir;
var elementID = document.getElementById(new_convertir + "_d");
var div = document.createElement("div"); = "50%"; = "right"; = "inline";
elementID.appendChild(div, elementID);
div.innerHTML = ' Convertir';

documew_cnt.getElementById(neonvertir).style.width = "0%";
document.getElementById(sFieldID).ondblclick = function () { DateDifference(); };

I get this result :

How To retrieve the list of organizations using C#

Open your solution in VS , right-click the name of the project that you want to add the service to, and then click Add Service Reference.

The Add Service Reference dialog box appears


add service reference

click Discover.

All WCF services in the current solution are added to the Service list.

In the Service list, expand the node for the service that you want to use and select a service contract.

In the Namespace box, enter the namespace that you want to use for the reference

Click OK to add the reference to the project.

A service client (proxy) is generated, and metadata describing the service is added to the app.config file

Then add the following references assemblies

  1. Microsoft.crm.sdk.proxy
  2. Microsoft.Xrm.Sdk
  3. System.ServiceModel




and this is the result


fetchxml linked-entity with lookup filter

Hello, In this article i will share with you how to add a lookup filter to a linked entity with Fetchxml

In the serviceappointment entity ,  i added  a lookup  field “new_contract”  to diplay the list of contract,
 so i want to display the list of contract of the selected account.

i create a fetchxml filter and i added it to javascript function :

function preFilterLookup() {
Xrm.Page.getControl("new_contrat").addPreSearch(function () {

function getlookupCustomer()
var lookupObject = Xrm.Page.getAttribute("customers");

if (lookupObject != null) {

var lookUpObjectValue = lookupObject.getValue();

if ((lookUpObjectValue != null)) {

var lookuptextvalue = lookUpObjectValue[0].id;
return lookuptextvalue;

function addLookupFilter() {
var customer = getlookupCustomer();

if (customer != null) {

fetchXml = ""
+ " "
+ "";