Answered by:
CRM 2011: Create custom workflow activity with dynamic lookup input argument

Question
-
Hi all,
I'm new in developing custom workflows activities, and I have created a custom workflow activity with entity reference input argument for opportunity, this input argument is used to receive opportunity that has been created in an earlier step in the workflow.
Is there anyway to make this input argument accept lookups from any entity so that I can use this activity with any workflow ?
Thanks and best regards..Sunday, November 4, 2012 12:14 PM
Answers
-
Hi,
you can't do this, you have to specify specific entity name in entity reference type. refer: http://msdn.microsoft.com/en-us/library/gg327984.aspx#ReferenceTargetAttributeforEntityReferenceType
Contact Me
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by HIMBAPModerator Sunday, November 4, 2012 4:56 PM
- Marked as answer by Jamie MileyModerator Tuesday, February 4, 2014 3:17 PM
Sunday, November 4, 2012 4:55 PMModerator
All replies
-
Hi,
you can't do this, you have to specify specific entity name in entity reference type. refer: http://msdn.microsoft.com/en-us/library/gg327984.aspx#ReferenceTargetAttributeforEntityReferenceType
Contact Me
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by HIMBAPModerator Sunday, November 4, 2012 4:56 PM
- Marked as answer by Jamie MileyModerator Tuesday, February 4, 2014 3:17 PM
Sunday, November 4, 2012 4:55 PMModerator -
Hi,
I hope its not possible, because you need to pass the entity name as a reference type.
Monday, November 5, 2012 11:49 AM -
So how to make the custom activity working will all entities ?Monday, November 5, 2012 2:01 PM
-
I guess one thing to achieve this using context to get relevant entity, so if workflow is running for opportunity it will work for opportunity and if workflow is for task then it will work flow task record, see example article for this
http://crmentropy.blogspot.co.uk/2010/11/delete-this-record-custom-workflow.html
MayankP
My Blog
Follow Me on TwitterMonday, November 5, 2012 5:21 PM -
how to use context while defining input argument !!Tuesday, November 6, 2012 12:24 PM
-
hi Mostafa,
[Input("Display Name")]
[ReferenceTarget("logicalNameOfEntity")]
public InArgument<EntityReference> ExampleName { get; set; }now this will give you lookup field to select old records.
Mark as answer, if this helps you.
Friday, November 9, 2012 12:47 PM -
Hi Mostafa,
context will get defined automatically depending upon which record this workflow is running, so if you workflow is running for opportunity then context.EntityName will return Opportunity..
MayankP
My Blog
Follow Me on TwitterFriday, November 9, 2012 1:35 PM -
Hi Mostafa,
context will get defined automatically depending upon which record this workflow is running, so if you workflow is running for opportunity then context.EntityName will return Opportunity..
Again..How to use context while defining input argument !!
I tried the below:
[Input("Filed Name:")] [ReferenceTarget(context.EntityName)] public InArgument<EntityReference> Reference { get; set; }
And it is not workingMonday, November 12, 2012 12:30 PM -
As Mahender replied earlier, it is not possible to make the ReferenceTarget dynamic. As an attribute, it has to have a static value at compile time; the context is only relevant at runtime. This means it is not possible to write a custom workflow activtiy that could take an entity of any type as an InputParameter.
Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk
Monday, November 12, 2012 2:57 PMModerator -
I don't see ReferenceTarget used in the 2013 example code. No longer needed?Monday, February 3, 2014 8:38 PM