Dynamically set the ReferenceTarget attribute for custom workflow work in CRM 2011

I have a custom workflow that creates an entry based on the passed input parameters (lookup_name and name). Now I want to be able to pass the created record as an output parameter. But for an OutArgument declaration of type EntityReference, I have to set the ReferenceTarget attribute. Since I do not know what type of entity is being created, I want to be able to dynamically set this attribute. When I try to use a property or variable inside the ReferenceTarget attribute, it does not recognize it.

How can I do it? 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; } 
+4
source share
4 answers

As far as I know, you cannot, I suspect that this is support for the behavior of the workflow editor, how will he find out what options to present?

When I had this situation in the past, I created a visual studo template that I can use to quickly create the different versions that I need.

0
source

The best work (not accurate) is to create as many input parameters as possible, since many types of entities that you suspect can be passed as a ReferenceTarget, then, based on the conditions in your workflow, invoke the user workflow and set the input data and then in the Execute method of your workflow you can check which input parameter is Not Blank and process it accordingly.

The input parameters of the workflow remain internal to the developer, so if it’s good while you are doing your work and have the flexibility to use the same user activity of the workflow in different scenarios, especially when you can’t imagine what type of entity reference you will be have to deal with.

0
source

EntityReference, by its nature, has a target type. You cannot change this. Most likely, you are better off starting the plugin or following the following logic in your workflow assembly if these requirements are dynamic.

0
source
 //Set lookup for Account(Customer) [RequiredArgument] [Input("Select Account to Assign")] [ReferenceTarget("account")] public InArgument<EntityReference> account { get; set; } 
-1
source

Source: https://habr.com/ru/post/1439743/


All Articles