5

I have a custom workflow activity that creates a record based on the input parameters passed (entityName and Name). Now, i want to be able to pass the created record as an output parameter. But to declare an OutArgument with EntityReference type, I have to set the ReferenceTarget attribute. Since I do not know which entity type is being created, I want to be able to set this attribute dynamically. When I try to use a property or variable inside the 'ReferenceTarget' attribute, it is not recognizing it.

How do i do this ? Please help.

[Input("Entity Name")]
public InArgument<string> EntityName { get; set; }

[Input("Name")]
public InArgument<string> Name { get; set; }

[Output("Created Record")]
[ReferenceTarget("contact")]     <<=== how do i set this dynamically??
public OutArgument<EntityReference> CreatedRecord { get; set; }

5 Answers 5

0

As far as I know you cant, I suspect this is to support the behaviour of the workflow editor, how would it know which options to present?

When I've had this situation in the past I created a visual studo template which I can use to quickly generate the various versions I needed.

0

Best work around (not a neat one) is to create as many input parameters as many different entity types you suspect may need to be passed as ReferenceTarget, then based on conditions in your workflow call the custom workflow activity and set apt input parameter and then in the Execute method of your workflow you can check which input parameter is Not Blank and process accordingly.

The workflow input parameters remain internal to the developer so if it fine as long as you get your work done and have flexibility of using the same custom workflow activity in different scenarios especially when you have no idea what type of entity reference you will have to deal with.

0

An EntityReference by nature has a target entity type. You cant change that. You're probably better off kicking off a plugin or performing the subsequent logic within the workflow assembly if the requirements are that dynamic.

0

That is actually not possible as of now, but there is this workaround.

I suggest creating a custom entity call Context with a reference to all the input parameters you are planning to pass. And populate the context[""] as EntityReference to return it back as Output.

[Output("Created Record")]
[ReferenceTarget("new_context")]
public OutArgument<EntityReference> CreatedRecord { get; set; }

//set whatever you wanted to export
var entity = new Context();
entity["new_contact"] = ? //populate contact if created as per input
entity["new_account"] = ? //populate account if created as per input
// and so on
-1
//Set lookup for Account(Customer)
[RequiredArgument]
[Input("Select Account to Assign")]
[ReferenceTarget("account")]
public InArgument<EntityReference> account { get; set; }
1
  • 3
    I think you need to elaborate on your answer.
    – JoshDM
    Jan 25, 2013 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.