Set ActivityParty for DynamicEntity


Hi,

To set activityparty property in case of DynamicEntity we need to make use DynamicEntityArrayProperty.

Below is the sample code for creating an appointment programmatically using DynamicEntity and setting requiredattendees which is an ActivityParty property.

CrmSdk.CrmAuthenticationToken myToken = new CrmAuthenticationToken();

        myToken.OrganizationName = "orgname";

        myToken.AuthenticationType = 0;

        CrmSdk.CrmService myService = new CrmService();

        myService.CrmAuthenticationTokenValue = myToken;

        myService.Credentials = System.Net.CredentialCache.DefaultCredentials;

        DynamicEntity myAppointment = new DynamicEntity();

        myAppointment.Name = EntityName.appointment.ToString();

        StringProperty subject = new StringProperty();

        subject.Name = "subject";

        subject.Value = "Test Subject";

        // Set a contact for party

        DynamicEntity requiredAtt1 = new DynamicEntity();

        requiredAtt1.Name = "activityparty";

        // create a contact property

        LookupProperty contactProp = new LookupProperty();

        contactProp.Name = "partyid";

        Lookup contactLookup = new Lookup();

        contactLookup.type = "contact";

        contactLookup.Value = new Guid("{2DE7671B-987D-DE11-8AB8-0003FFD21C1C}");

        contactProp.Value = contactLookup;

        // add contact property

        requiredAtt1.Properties = new Property[] { contactProp };

        // Set an account for party

        DynamicEntity requiredAtt2 = new DynamicEntity();

        requiredAtt2.Name = "activityparty";

        // create an account property

        LookupProperty accountProp = new LookupProperty();

        accountProp.Name = "partyid";

        Lookup accountLookup = new Lookup();

        accountLookup.type = "contact";

        accountLookup.Value = new Guid("{A4BB3561-748D-DE11-8CD4-0003FFD21C1C}");

        accountProp.Value = accountLookup;

        // add account property

        requiredAtt2.Properties = new Property[] { accountProp };

        // create to property. it is an dynamic entity array

        DynamicEntityArrayProperty raProp= new DynamicEntityArrayProperty();

        raProp.Name = "requiredattendees";

        // add contact and account activity parties

        raProp.Value = new DynamicEntity[] { requiredAtt1, requiredAtt2 };

        // set scheduledStart date

        CrmDateTimeProperty scheduledStart = new CrmDateTimeProperty();

        scheduledStart.Name = "scheduledstart";

        CrmDateTime ss = new CrmDateTime();

        ss.Value = DateTime.Now.ToString();

        scheduledStart.Value = ss;

        // set scheduledend date

        CrmDateTimeProperty scheduledEnd = new CrmDateTimeProperty();

        scheduledEnd.Name = "scheduledend";

        CrmDateTime se = new CrmDateTime();

        se.Value = DateTime.Now.AddHours(1).ToString();

        scheduledEnd.Value = se;        

        myAppointment.Properties = new Property[] { subject,raProp, scheduledStart,scheduledEnd };

        Guid mycontactGuid = new Guid();

        try

        {

            mycontactGuid = myService.Create(myAppointment);

        }

        catch (SoapException ex)

        {

         //   handle exception

        }

Bye..

The ‘System.ServiceModel/ServiceHostingEnvironment’ configuration section cannot be created. The Machine.config file is missing information error on opening CRM


Hi,

I got this error while opening CRM 4 !

The solution was to run the following command

ServiceModelReg.exe –i

which could be found at

C:Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation.

Followed by an IISReset.

However in few cases to resolve it, it requires reinstallation of IIS.

ServiceModel Registration tool with -i option

Registers this version of WCF and update scriptmaps at the Internet Information Services (IIS) metabase root and for all scriptmaps under the root. Existing scriptmaps of lower versions are upgraded to this version.

 

Bye.

Email Description Field / Body field and JavaScript in CRM


Hi,

To set description field in email with formatting instead of DataValue we need to use

document.all[‘descriptionIFrame’].contentWindow.document.body.innerHTML="One <br/> Two";

as it is rendered as IFrame.

And in form’s onload to set it we need to use script like this

document.all[‘descriptionIFrame’].attachEvent( "onreadystatechange", stateChanged)
return;
function stateChanged()
{
     if (document.all[‘descriptionIFrame’].readyState==4 ||document.all[‘descriptionIFrame’].readyState=="complete")
          {
     document.all[‘descriptionIFrame’].contentWindow.document.body.innerHTML='<span style="color: #6600cc">this </span>is a <span style="font-weight: bold; font-style: italic">test</span>’;
     }
}

Check the entire thread here !!

http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/e349b7fc-f42a-4fa5-aaa4-ba01673a73ed

 

Bye..

Code to retrieve status value based on status label in CRM 3


This code is for retrieving status value based on status text for salesorder entity.

 

public int RetrieveStatusValue(EntityName Entity, string StatusValue)
   {

       int intStatus = 0;

       MetadataService MetaService = new MetadataService();
       MetaService.Credentials = System.Net.CredentialCache.DefaultCredentials;

       AttributeMetadata am = MetaService.RetrieveAttributeMetadata(Entity.ToString(), "statuscode");
       StatusAttributeMetadata sm = (StatusAttributeMetadata)am;

       foreach (StatusOption so in sm.Options)
       {
           if (so.State == 0)
           {
               if (so.Description.Trim().ToLower() == StatusValue.ToLower())
               {
                   intStatus = so.OptionValue;
                   break;
               }
           }
       }

       am = null;
       sm = null;

       MetaService.Dispose();

       return intStatus;
   }

 

To call the function

RetrieveStatusValue(EntityName.salesorder, "Draft");

 

Bye.

Calling CrmService from Java


While searching for the same I found these article !!

http://rabout.com/?q=ms_dynamics_crm_3_api_axis2

http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/caf5fa3f-c5f0-43a9-8cfc-4fdb88bb6248

http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/94524d3c-cf66-4766-8c0c-1a22d9669c24

Bye..

System.Net.WebException: The request failed with HTTP status 404: Not Found Error While Using CrmService Retrieve in callout.


Hi,

I was getting this error on all my callouts, initially they all were running fine. Recently we had tried upgrading CRM 3.0 to CRM 4.0 and had failed in that, so we had CRM 3.0 reinstalled on that machine.

This time the port was different i.e. 100 instead of 5555. And we were using our own config files for callout where we were setting crm’s Url. I modified the url there, followed by an IISRESET but still same error.

Finally i updated my web references( in visual studio)  for my callout to point to the new url with the new port, rebuild it and deployed this callout. This resolved the issue.

Bye..

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓