Monthly Archives: November 2010

Close Activity based on Due Date using workflow


 

I got one requirement from my client where we need to complete Email activity based on it’s Due date. so I have to check if current date is equal to email’s due date then close email activity. So I created a workflow to implement this. Here are the steps to create workflow

1.       Create new workflow select Entity as Email, Give some name to workflow like “Close Email”, Select new Blank workflow.

2.       Select Run when record is created.

3.       Select “Wait Condition”

 

Timeout until Email:Due Date

5.       Select Row under and add new step “Change record status” and set email status as completed.

6.       It should look like as below.

                                           

 

7.       Publish your workflow and create Email record and set due date. workflow will close email activity based on it’s due date.

 

Cheer !!!

Leave a comment

Filed under MS CRM 4.0, Workflow & Plugin Development

Create Opportunity Relationship record

Sometime we need to create “Opportunity Relationship” record through code. We can use below code to create Opportunity relationship record. Basically we need to set three values while creating opportunity relationship record customerid, opportunityid and opportunityroleid.

//I have used Dynamic entity to create opportunity relationship record

DynamicEntity  _OpportunityRelationship = new DynamicEntity();

//Set entity name as “customeropportunityrole”         

 _OpportunityRelationship.Name = “customeropportunityrole”;

//Create property to set customer 

CustomerProperty _OpportunityCustomer=new CustomerProperty();

  _ OpportunityCustomer.Name=”customerid”;

 _ OpportunityCustomer.Value=new Customer();

 _ OpportunityCustomer.Value.type = “account”; //Set customer type (I am using account here)

 _ OpportunityCustomer.Value.Value=CustomerGUID;  //replace CustomerGUID with customer GUID

_OpportunityRelationship.Properties.Add(_OpportunityCustomer);

//set Opportunity ID 

LookupProperty _OpportunityID=new LookupProperty();

 _ OpportunityID.Name=”opportunityid”;

 _ OpportunityID.Value=new Lookup();

 _ OpportunityID.Value.Value=OpportunityID; //replace OpportunityID with opportunity GUID

 _OpportunityRelationship.Properties.Add(_OpportunityID);

 //Set Opportunity Role

//you can create Relationship Roles from Setting->Business Management->Relationship Roles        

 LookupProperty _OpportunityRole = new LookupProperty();

 _OpportunityRole.Name = “opportunityroleid”;

 _OpportunityRole.Value = new Lookup();

   _OpportunityRole.Value.Value =GUIDofRelationshipRole; //Replace GUIDofRelationshipRole with Relationship role Guid.

   _OpportunityRelationship.Properties.Add(_OpportunityRole);

  TargetCreateDynamic targetCreate = new TargetCreateDynamic();

  targetCreate.Entity = _OpportunityRelationship;

// 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);

 Hope it will help somebody.

Cheer 🙂

Leave a comment

Filed under MS CRM 4.0, Workflow & Plugin Development