locked
Error registering custom workflow assembly. RRS feed

  • Question

  • I have custom Workflow assembly that has one output parameter string type, when i try to register the assymbly i am getting error.

    Unhandled Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request.
    Detail: <detail><error>
      <code>0x8004501d</code>
      <description>Could not find a Public, Static field with name 'userProperty' of type DependencyProperty</description>
      <type>Platform</type>
    </error></detail>
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at PluginRegistrationTool.CrmSdk.CrmService.Create(BusinessEntity entity)
       at PluginRegistrationTool.RegistrationHelper.RegisterPluginType(CrmOrganization org, CrmPlugin plugin)
       at PluginRegistrationTool.PluginRegistrationForm.btnRegister_Click(Object sender, EventArgs e)

     

    i have checked everywhere in the code, no problem with the code, i have the rihgt name, right parameter, adn tyopes in the code for the dependency property dont know why is this happening, but it just errored out everytime, i have tried changing VS2008, VS2010, no hope, even tried changing fx3.0, fx3.5 etc. can someone please help.

    code is.

    ///

      [CrmWorkflowActivity("Return Workflow Executing User", "ITCI3L Custom Workflow Functions")]
            public class ReturnUserName : Activity
            {
                // Override this method with our custom logic
                protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
                {
                    try
                    {
                        //Get context 
                        IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
                        IWorkflowContext ctx = contextService.Context;
                        ICrmService crmService = ctx.CreateCrmService();
                        // Get the Username from the context and pass it back to the output parameter
                        systemuser _User = (systemuser)crmService.Retrieve(EntityName.systemuser.ToString(), ctx.UserId, new ColumnSet(new string[] { "fullname" }));
                        this.user= _User.fullname;
                       
                       
                    }
                    catch (Microsoft.Crm.Sdk.InvalidPluginExecutionException ex)
                    {
                        throw new InvalidPluginExecutionException("Error occurred in the Return Workflow Executing User.", ex);
                    }
                    catch (System.Exception ex)
                    {
                        throw new InvalidPluginExecutionException("Error occurred in the Return Workflow Executing User.", ex);
                    }

                    return base.Execute(executionContext);
                }

                //output user name
                public static DependencyProperty property = DependencyProperty.Register("user",typeof(string),typeof(ReturnUserName));
                
                [CrmOutput("user")]
                [CrmReferenceTarget("systemuser")]
                public string  user
                {
                    get { return (string)base.GetValue(property); }
                    set { base.SetValue(property, value); }

                }


            }

    // let me know if any issues in that..

     

     


    BharatKumar Bambhaniya Software Developer.
    Friday, July 30, 2010 2:24 PM

Answers

  • Bharat ,

    Follow these steps

    1. Create new WF, select your entity and set other options like run when record is delete

    2. First select you custom wrokflow step.

    3. select create record and select your custom entity.

    4. Set it's property, while setting it's properties, workflow from "Look for" and then your output variable name from below dropdown

    Let us know


    Mahain : http://mahenderpal.wordpress.com
    • Marked as answer by Jim Glass Jr Monday, August 2, 2010 4:52 PM
    Monday, August 2, 2010 10:27 AM
    Moderator

All replies

  • i ahve also tried removing property attribute

     [CrmReferenceTarget("systemuser")]

    but no hope...


    BharatKumar Bambhaniya Software Developer.
    Friday, July 30, 2010 2:25 PM
  • your dependency property should be named as follows

    public static DependencyProperty userProperty = DependencyProperty.Register("user",typeof(string),typeof(ReturnUserName));

    it must always be suffixed with "Property" in the end of the name of the actual instance property.
    This is what it says in the error message too

    • Proposed as answer by ameed sheikh Friday, July 30, 2010 2:43 PM
    Friday, July 30, 2010 2:43 PM
  • Systemuser is lookup. So you should use following code:

     

                public static DependencyProperty userProperty = DependencyProperty.Register("user",typeof(Lookup),typeof(ReturnUserName));
                
                [CrmOutput("user")]
                [CrmReferenceTarget("systemuser")]
                public Lookup  user
                {
                    get { return (Lookup)base.GetValue(userProperty); }
                    set { base.SetValue(userProperty, value); }

                }

     

    in the case it is string you should use following code:

                public static DependencyProperty userProperty = DependencyProperty.Register("user",typeof(string),typeof(ReturnUserName));
                
                [CrmOutput("user")]
                public string  user
                {
                    get { return (string)base.GetValue(userProperty); }
                    set { base.SetValue(userProperty, value); }

                }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Friday, July 30, 2010 4:42 PM
    Moderator
  • However if you keep it string i.e, if you just want fullname of user then you do not need to register [CrmReferenceTarget("systemuser")]. But as Andriy said if you want to return systemuser object then it needs to be a lookup

    • Proposed as answer by ameed sheikh Friday, July 30, 2010 4:48 PM
    Friday, July 30, 2010 4:47 PM
  • Thank you all, apart from what we have discussed, i have observed one more thing that if we take property type as simple "string" then it is not supported it has to be "String", so that is also need to take care while defining Dependency properties.

    Any idea on how we can get this output property as one of the workflow property, so that in the design mode i can set it as one of the related record's field.

    for example on the delete action i am creating one entitiy record to clone the deleted record but i also needed the user who has deleted the recrd, so by this workflow i am able to get the executing user, but in the design i am unable to set it against the one of teh entities property, how can i do that, how can i make the output properties available in the design mode to be used to set the other entities field. please help.


    BharatKumar Bambhaniya Software Developer.
    Monday, August 2, 2010 4:53 AM
  • Hi Bharat,

    if you are writing custom workflow, having out variable then it should be available to all entities after registering your custom workflow.

    I will strongly suggest you to go through Business Productivity Workflow that is freely available in code plex

     


    Mahain : http://mahenderpal.wordpress.com
    Monday, August 2, 2010 5:54 AM
    Moderator
  • Hi mahen,

    thanks again, but i have done the same thing and after i register my workflow i dont see it available to all of the entitied in the designer, for example, i cant set the username(output property) to my custom entities string field. that is what i exactly need it to be able to, but this out put property is not available in the designer.. donno know why..


    BharatKumar Bambhaniya Software Developer.
    Monday, August 2, 2010 6:21 AM
  • Hi,

    Could you please tell me detail steps what that you are following in designer to set it ???


    Mahain : http://mahenderpal.wordpress.com
    Monday, August 2, 2010 6:30 AM
    Moderator
  • OK.

    1. onDelete of the record, i am creating new entity record XYZ.

    2. in the set property i set its name, modified, fields etc by the help of the form assistance.

    now after the workflow activity is created i have this workflow activity called, Return User as saparate activity in the designer, and when i add that in workflow, i see it as saparate step, and when i click set properties,

    i have a form to set property, adn in the right side form assistance, when i select create record activity step i dont have access to any of its property or not even any other properties, the set property form it self is empty. only, propery name, datatype and value labels are there. its just disconencted with anyother entities.

     


    BharatKumar Bambhaniya Software Developer.
    Monday, August 2, 2010 10:01 AM
  • Hi Bharat,

    That is because you have only created output variable not input variable right ???

    so just select it just like as step (only after that you can set output variable)

    check your output varible you will get it with all entities.

    Let us know if you have any other query


    Mahain : http://mahenderpal.wordpress.com
    Monday, August 2, 2010 10:09 AM
    Moderator
  • But the fact is i need to set one of the record field with this output field, but i am unable to.

    on the delete record i am returning this user, and in the designer i need to set it as "Deleted by" field of one of the entities but i am unable to get this that way.. dont know what is wrong but i dont see this with other entities too.


    BharatKumar Bambhaniya Software Developer.
    Monday, August 2, 2010 10:13 AM
  • Bharat ,

    Follow these steps

    1. Create new WF, select your entity and set other options like run when record is delete

    2. First select you custom wrokflow step.

    3. select create record and select your custom entity.

    4. Set it's property, while setting it's properties, workflow from "Look for" and then your output variable name from below dropdown

    Let us know


    Mahain : http://mahenderpal.wordpress.com
    • Marked as answer by Jim Glass Jr Monday, August 2, 2010 4:52 PM
    Monday, August 2, 2010 10:27 AM
    Moderator
  • Ok, i will give it a try.. my dev env is down.. so i will update as soon as i am up. thanks for help.
    BharatKumar Bambhaniya Software Developer.
    Monday, August 2, 2010 10:35 AM