I am quite new to CRM and I have now built a Custom Activity. The Activity is global and not bound to an Entity.
The Activity is triggered by a Button placed on a form (entity) in CRM.
Now I need to retrieve the RecordId and the OwnerId of the Record in context.
On clientside this is easy and also with a plugin. But I was not able until now to figure out how to get these Guids in my Custom Activity.
EDIT: I've tried with this, but the Guid is always "000-00-000-000...."
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
Guid recordId = context.PrimaryEntityId;
Maybe this is due to the fact that my CodeActivity is Global and I do not have a"PrimaryEntity"?
Any help is really appreciated!
If your Action is global then by definition it is not bound to any entity, so you will not have any "context" information - you can call this action even from outside of CRM, the system will not pass inside any information based on the form that you are currently on.
Your global action should have some input parameters and you should pass them while calling the Action (from JavaScript as I understood correctly). This can be entity Id, entity type, or whatever else you need. Then you should pass them inside your Custom Workflow Activity (using Input Parameters of Custom Activity). Or you can simply recreate this Action as bound action (but in such case you will still have to pass the bound entity when calling the action, system will not magically inject the context information for you)