Custom fields in Custom workflow

By using custom workflow , i will make Auto-numbering in CRM 4.0 .

 

I have created a readonly field on Account entity” new_auto” to hold the “Guid” of

Account. As GUID is always unique , so there is no question about it being duplication. We can use prefix whatever we want.  As one can see AC- (GUID). I will use cutom workflow to obtain the GUID of entity when it is created and then update the entity with the prefix+ GUID.

 

 

 

 

 

using System;

using System.ComponentModel;

using System.ComponentModel.Design;

using System.Collections;

using System.Drawing;

using System.Workflow.ComponentModel.Compiler;

using System.Workflow.ComponentModel.Serialization;

using System.Workflow.ComponentModel;

using System.Workflow.ComponentModel.Design;

using System.Workflow.Runtime;

using System.Workflow.Activities;

using System.Workflow.Activities.Rules;

using Microsoft.Crm.Sdk;

using Microsoft.Crm.SdkTypeProxy;

using Microsoft.Crm.Workflow;

using Microsoft.Crm.Workflow.Activities;

using Microsoft.Crm.Sdk.Query;

 

namespace Number

{

      [CrmWorkflowActivity(“OneTest”, “AccountNumber”)]

 

    public partial class Activity1 : SequenceActivity

    {

 

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

        {

 

 

            IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));

 

            IWorkflowContext context = contextService.Context;

 

      ICrmService crmService = context.CreateCrmService();

 

      WhoAmIRequest systemUserRequest = new WhoAmIRequest();

 

      WhoAmIResponse systemUser = (WhoAmIResponse)crmService.Execute(systemUserRequest);

 

      ColumnSet cols = new ColumnSet();

 //Getting the ID of entity which unqiue itself

 

      Guid guidID = new Guid(this.objectID.Value.ToString());

 

          // i am using “AC” before GUID.This field will hold the GUID of account

 

      string Number  = “AC-=” + guidID;

 

      TargetRetrieveAccount target = new TargetRetrieveAccount();

 

      target.EntityId = guidID;

      RetrieveRequest getAccount = new RetrieveRequest();

 

      getAccount.ReturnDynamicEntities = true;

 

      getAccount.Target = target;

 

      getAccount.ColumnSet = new AllColumns();

 

      RetrieveResponse retrieved = (RetrieveResponse)crmService.Execute(getAccount);

 

      DynamicEntity regardingAccount = (DynamicEntity)retrieved.BusinessEntity;

 //i am using custom field to hold the value of “GUID” .

 

      if (regardingAccount.Properties.Contains(“new_auto”))

      {

 

          regardingAccount.Properties[“new_auto”] = Number;

 

      }

 

      else

      {

 

          regardingAccount.Properties.Add(new StringProperty(“new_auto”, Number));

      }

 

         crmService.Update(regardingAccount);

 

     

           return ActivityExecutionStatus.Closed;

 

        }

 

 

        public static DependencyProperty objectIDProperty = DependencyProperty.Register(“objectID”, typeof(Lookup), typeof(Activity1));

 

 

 

        [CrmInput(” objectID”)]

 

       [CrmReferenceTarget(“account”)]

 

       // [CrmReferenceTarget(“automatic.crm.new_audit”)]

       // public.automatic.crm.Lookup

 

        public Lookup  objectID

        {

 

            get

            {

 

                return (Lookup)base.GetValue(objectIDProperty);

 

            }

 

            set

            {

 

                base.SetValue(objectIDProperty, value);

 

            }

        }

 

  }

}

Finally we need to publish the workflow using developer tool and then calling the assembly from workflow.

 

Advertisements

10 Responses to “Custom fields in Custom workflow”


  1. 1 Stu January 20, 2009 at 11:57 am

    So how would I do the same for a custom entity, not a system entity?

  2. 2 marketing digital May 5, 2013 at 4:20 pm

    NET development, PHP development, B2B and B2C portal development,
    Business and community portal, web application development, live chat
    integration, content management system, payment gateway integration, e-commerce application development and shopping cart.

    Our professional press release distribution is under our Mass
    Media Distribution program and includes press news distribution to
    a pool of approximately 80,000 journalists, 4000+ web sites, opt in journalists that request news to be sent directly to their inbox and of course relevant trade publications.

    Finally- Aid and enable them to defeat their
    enemies.

  3. 3 isolation toit lille May 5, 2013 at 7:46 pm

    The roofing industry has been expanding along with the
    roof repairing business. After asking for licensing information,
    it is important to also verify if the business is
    a legitimate one. Why do roof repair contractors suffer these unsavoury conditions.

  4. 4 mortgage loan debt consolidation refinance home improvement May 22, 2013 at 1:49 am

    Twenty five percent space of the town is under the green cowl that makes this city additional viable and recent particularly within
    the monsoon season. Samsung M620 Black mobile is just big enough to display four icons side by
    side and measures only 1. There are a lot of options in mobile phones available on the market today.

  5. 5 Ruben May 22, 2013 at 6:05 pm

    We turned on the wireless connection on both and checked that they could
    connect to the internet and worked at a decent pace.
    The built quality on the XPS is also a solid one with aluminum carbon chassis,
    giving it a sturdy, premium look. Aided by the Pills rapidly getting best tablet pc all of the direct device when using the iphone, it is really distinct that we should expect to witness it develop worldwide recognition
    for countless years.

  6. 6 selectionner agence immobiliere montrouge June 26, 2013 at 5:11 am

    Italian food lovers also tend to be picky and will place every dish under scrutiny.
    Every day you should make a habit of doing the 2 or 3 things that will help you build your career
    and market share. Competitions in bareback riding, steer wrestling, team roping, tie-down roping, and saddle bronc riding
    demonstrate the skills used by the original cowboys in
    the Austin region.

  7. 7 hms bounty - sandy July 12, 2013 at 4:02 pm

    Heya i am for the first time here. I came across this board and I find It really useful &
    it helped me out a lot. I hope to give something back and aid others
    like you helped me.

  8. 8 treadmill reviews July 13, 2013 at 6:46 am

    certainly like your web-site but you need to test the
    spelling on several of your posts. Many of them are rife with spelling problems and I find it very bothersome to inform the
    truth however I will surely come back again.

  9. 9 My Webpage October 6, 2014 at 2:47 pm

    Heya i will be for that primary time period the following. I ran across this particular mother board and I believe that it is definitely beneficial & this solved the problem available a good deal hr services. Lets hope to make available some thing just as before and aid people such as you aided us.


  1. 1 Retrieve Custom Fields | keyongtech Trackback on January 18, 2009 at 5:23 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: