.NET Framework missing from Visual Studio 2010 new project dialog box


To resolve this issue, download and install .NET Framework 3.5 sp1.

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&displaylang=en

Or if it is Windows Server 2008 R2,  just enable the .NET Framework 3.5.1 Features using Server Manager or else you will get the following error

“You must use role management tool to install or configure Microsoft .NET Framework 3.5”

Bye.

Using OrganizationServiceClient in CRM 2011


 Add Service Reference to the Organization WCF service in the application.

URL àhttp://servername:port/OrganizationName/xrmServices/2011/organization.svc 

Use the following code to perform various functions using OrganizationServiceClient 


Entity myContact = new Entity();

myContact.LogicalName = “contact”; 

AttributeCollection myAttColl = new AttributeCollection();

myAttColl.Add(new KeyValuePair<string, object>(“lastname”, “Rana”));

myContact.Attributes = myAttColl;
ClientCredentials credentials = new ClientCredentials();

Uri organizationUri = new Uri(http://servername:port/organizationname/xrmServices/2011/organization.svc&#8221;);

try
{
OrganizationServiceClient orgClient = new OrganizationServiceClient();
 

orgClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(“username”, “password”, “domain”); 

orgClient.Create(myContact);

}
catch (Exception ex)
{

throw ex;

} 

Hope it helps.

Using JavaScript to consume a WCF service


Suppose this is our simple WCF service which takes the name as input and returns the resulting string with Hello appended to it.

namespace HelloWorldWCFService{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(string name);
}
}

namespace HelloWorldWCFService{
public class Service1 : IService1 {
public string GetData(string name) {
return “Hello “ + name;

}}}
It uses BasicHttpBinding.

Now this would be our JavaScript function which can consume the above WCF service.

function MyRequest() {var xmlhttp = new XMLHttpRequest();

xmlhttp.open(‘POST’, http://localhost:64833/Service1.svc&#8217;, false);xmlhttp.setRequestHeader(‘SOAPAction’, http://tempuri.org/IService1/GetData&#8217;);

xmlhttp.setRequestHeader(‘Content-Type’, ‘text/xml’);
var data = ;

data += ‘<s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/”>&#8217;;data += ‘ <s:Body>’;

data += ‘ <GetData xmlns=”http://tempuri.org/”>&#8217;;

data += ‘ <name>Nishant</name>’;

data += ‘ </GetData>’;

data += ‘ </s:Body>’;

data += ‘</s:Envelope>’;xmlhttp.send(data);

alert(“status = “ + xmlhttp.status);alert(“status text = “ + xmlhttp.statusText);

alert(xmlhttp.responseText); 

}

Here for

xmlhttp.setRequestHeader(‘SOAPAction’, http://tempuri.org/IService1/GetData&#8217;); 

We can get the value for SOAPAction from the wsdl of the WCF service. 

Open the http://localhost:64833/Service1.svc?wsdl

Search for soapAction there.

We would find soapAction value there.

<wsdl:operation name=”GetData“>  <soap:operation
soapAction=”http://tempuri.org/IService1/GetData style=”document” />
<wsdl:input>

Hope it helps !

CRM Shortcut in CRM 2011 Dialogs


Hi I was just wondering how we can use CRM Shortcut radio button option that appears in Insert Hyperlink dialog box of Dialogs in CRM 2011.

After searching for it, I found the following post which says that we should ignore that button as it won’t be there in the final release.

http://social.microsoft.com/Forums/en/crm2011beta/thread/d012ae9e-4bc5-4bdb-ae6f-c58da16882dc

Hope it helps !

Rename Domain in Windows Server 2008


Hi,

I was assigned the task of renaming the domain. This post was extremely useful.

http://www.shariqsheikh.com/blog/index.php/200804/how-to-rename-a-windows-server-2008-domain/

I’ll put few of the steps from that post here 

“From the command prompt, I started out by running rendom /list which outputs an XML file (Domainlist.xml) to the directory where rendom resides. You edit that file to change your domain configuration to the new domain name. i.e ForestDNSZones, DomainDNSZones, Netbios name. See referenced link for details.

After you have modified the file you can run rendom /showforest which shows you the future configuration, verify and make changes if necessary.

Upload the changes you have made in the XML file: Run rendom /upload

Verify readiness of Domain Controller(s): Run rendom /prepare

Execute domain rename instructions: Run rendom /execute

After thats finishes up successfully, you should also run GPFIXUP tool to fix up GPO references to your old domain name.

Here is an example :

C:\Users\Administrator>gpfixup /olddns:08r2.lab /newdns:mcts.lab
Group Policy fix up utility Version 1.1 (Microsoft)

Start fixing group policy (GroupPolicyContainer) objects:
……..

Start fixing site group policy links:
.

Start fixing non-site group policy links:
….
gpfixup tool executed with success.

C:\Users\Administrator>gpfixup /oldnb:08r2 /newnb:mcts
Group Policy fix up utility Version 1.1 (Microsoft)

Start fixing group policy (GroupPolicyContainer) objects:
..
gpfixup tool executed with success.

Lastly, run rendom /clean”

Bye..

Sample function using SetStateRequest to deactivate record



// Get all the active records for a custom entity and deacitvate it

// In this case Custom Entity name is new_customentity and it has many to one relationship with contact record

 // So we are finding all the active custom entity records for a particular contact

 

// and deactivating it

 

private
void DeActivateCustomRecords(string contactID, IOrganizationService _service)
{
// setting contact id

ConditionExpression condition1 = new ConditionExpression();

condition1.AttributeName=“new_contactid”;

condition1.Operator =ConditionOperator.Equal;

condition1.Values.Add(contactID);


// and state code =0 -> active record

ConditionExpression condition2 = new ConditionExpression();

condition2.AttributeName =“statecode”;

condition2.Operator =ConditionOperator.Equal;

condition2.Values.Add(0);

 // And the condition

FilterExpression filterExpression = new FilterExpression();

filterExpression.AddCondition(condition1);

filterExpression.AddCondition(condition2);

filterExpression.FilterOperator =LogicalOperator.And;

 //Create a column set to get the custom entity records id
//we need them to disable the records

ColumnSet columns = new ColumnSet(“new_customentityid”);
// Create query expression.

QueryExpression query1 = new QueryExpression();

query1.ColumnSet = columns;

query1.EntityName =“new_customentity”;

query1.Criteria = filterExpression;

 try{

EntityCollection result= _service.RetrieveMultiple(query1);
foreach (Entity customEntityResult in result.Entities)
{

SetStateRequest setState = new SetStateRequest();

setState.EntityMoniker = new EntityReference();

setState.EntityMoniker.Id = customEntityResult.Id;

setState.EntityMoniker.Name = “new_customentity”;

setState.EntityMoniker.LogicalName = entityElgResult.LogicalName;

setState.State =new OptionSetValue();

setState.State.Value = 1;

setState.Status = new OptionSetValue();

setState.Status.Value = -1;

SetStateResponse setStateResponse = (SetStateResponse)_service.Execute(setState);

}

}
catch (Exception ex)
{
throw ex;

}

}

Hope it is useful !

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓