locked
Declaring Business Entity Parameter in Workflow.Config File (CRM 3.0) RRS feed

  • Question

  • Hello,

    in CRM 3.0 I'm working on updating fields in a custom entity. I'm writing a Workflow Assembly for this, because the Manual Workflow does not allow me to update with the carriage return characters...

    So I wrote a Workflow Assembly for updates. This is the header of my class:

    public void Update (BusinessEntity new_project)   //parameter type is a CRM entity called new_project

    It basically updates some fields in my custom entity called new_project.

    And then I modified my workflow.config file in CRM directory. I keep having trouble with the parameter in writing this method:


            <method name="Test SOW"
                assembly="ICHA.Workflow.dll"
                typename="ICHA.Workflow.SOW"
                methodname="Update"
                group="Custom Assemblies"
                isvisible="1"
                timeout = "7200">   
                <parameter name="new_project"/>        
            </method>

    I got the error saying System.String cannot be converted into Business Entity. Omit the " " in between new_project and I got another error saying Workflow.config is invalid.


    So I changed the above parameter line into <parameter name="new_projectid" type="lookup" entityname="new_project"/>

    For this I got another error saying Object System.Guid cannot be converted into Business Entity....


    I also tried to omit the parameter line and change to <entityname= "new_project" /> and it told me the the config file is invalid, and etc..

    If I didn't declare any parameters at all it will throw a tantrum too.

    My question is, how should I declare my Business Entity parameter into my Workflow.config file? I believe my Workflow Assembly is working well, I just have to declare it in the config file.

    Thanks in advanced for your help.
    Wednesday, December 9, 2009 11:31 PM

Answers

  • CRM won't pass a BusinessEntity to a Workflow Assembly; it will only pass a Guid. So, the following in the config file is correct:

    <parameter name="new_projectid" type="lookup" entityname="new_project"/>

    But you'll need to change your code so the method signature looks as follows, and you may need to call the Retrieve method to get attributes of your new_project entity:

    public void Update (Guid new_projectid)
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Thursday, December 10, 2009 2:37 PM
    Moderator

All replies

  • CRM won't pass a BusinessEntity to a Workflow Assembly; it will only pass a Guid. So, the following in the config file is correct:

    <parameter name="new_projectid" type="lookup" entityname="new_project"/>

    But you'll need to change your code so the method signature looks as follows, and you may need to call the Retrieve method to get attributes of your new_project entity:

    public void Update (Guid new_projectid)
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Thursday, December 10, 2009 2:37 PM
    Moderator
  • David, thank you for your reply.

    Now that we need to pass a Guid for this workflow to run, my question is, is this going to work for a record that has not yet been saved?

    For example a user is creating a new project, and he wants to run this Workflow to update the fields in his new record. However, since the record is not saved yet, how do I pass the project guid?

    Is there a way to update an entity without having to pass the guid of that entity to the function...? I know this is a confusing question.
    Thursday, December 10, 2009 6:56 PM
  • There is no way to run a workflow on a record before it has been saved, irrespective of what the workflow does. However, as soon as the record has been saved, then it will have a guid that can be passed to a workflow
    Microsoft CRM MVP - http://mscrmuk.blogspot.com   http://www.excitation.co.uk
    Friday, December 11, 2009 10:22 AM
    Moderator