In Dynamics CRM is it possible to check the Execution Order from within the plugin context? - plugins

When registering a plugin against Dynamics CRM you can specify the Execution Order (also known as Rank).
https://learn.microsoft.com/en-us/previous-versions/dynamics-crm2011/developer-articles/hh237515(v=crm.6)#bkmk_RegStep
Execution Order
Specifies the order, also known as rank, that plug-ins are executed within a pipeline stage. Plug-ins registered with an order value of 1 are executed first, followed by plug-ins registered with an order of 2, and so on. However, if there is more than one plug-in in a stage with the same order value, then the plug-in with the earliest compilation date is called first.
I want to check the value of this from inside the plugin, can I do so, and how?

Yes you can, not directly from Plugin Execution Context but using another retrieve service call.
var rank = service.Retrieve("sdkmessageprocessingstep",context.OwningExtension.Id,new ColumnSet(new[] { "rank" })).GetAttributeValue<int>("rank");

Related

How to execute a long running task in Microsoft Dynamics CRM and overcome the 2 minutes limitation?

I created a plugin that runs on update when updating 3 fields, the plugin will run a fetchXML and get the records from another entity that has the first record Guid as a lookup then I will apply a loop to update those records with the value of the 3 fields (the fields that have changed).
The problem is that the fetchXML return 1290 records (and it could be more or less) but there is a time limit of execution which is 2 minutes, this limitation apply to both plugin and custom workflow (sync or async), from my research you can't override this limitation in Dynamics crm online.
I really don't know how to solve this issue, it seems I can't use a console app either.
Are there any other possibilities?
In those situations - we will move the long running code to Azure Function and invoke it from the plugin.
Read more

Workfront Custom Filtering

I'm trying to create a filter to find a missing task in several Workfront plans. I have tried system filters with no luck.
I can filter if missing a field but not a task.
I am using the web interface. I am looking for a task with a specific name (i.e. Identify External Resources), that should be in multiple project plans, and I want to find plans without that task listed.
Your requirements are:
Find all projects
Filter for projects that do not contain the task 'identify external resources'
My assumptions are:
You want ALL projects that don't contain the named task
Your criteria is that the project either has the task or doesn't (you don't care if has 1 task of that name or 100)
The solution is:
Create a project-level report
Go into the filter tab
Switch to text mode and add the following:
tasks:name=identify external resources
tasks:name_Mod=cinotcontains
This will find all projects that don't have a task named 'identify external resources'. You can combine this with additional filter to add other tasks and/or status filters.

Call external web service from within Crm 2016

I have some functionality I need to implement in Dynamics Crm 2016. I need to scan all records for a custom entity and update any record where a certain condition is true. This is a bit too complex to do via a workflow (I can't change owner via a workflow step) so I'm thinking perhaps I could perform this logic in a custom plugin. I don't know if it makes sense to call this plugin from a workflow in crm though, as I need to perform the logic on all records for this particular entity, and I need the logic to run regularly, i.e. daily/weekly. What's the best way to do this?
I figured this out. It was actually possible to do entirely within Crm. What I was trying to do was the following.
I have a custom entity called announcement, and it has a custom field called embargo date.
I needed to somehow check periodically if the embargo date has been reached, meaning, is the embargo date today? If so, then I needed to change the owner of this entity.
If the embargo date has not yet been reached, then I need to wait until it is, checking the date again everyday till it is reached.
I managed this with a workflow. I added my check conditions, if they were true I assigned the entity to another user.
If my conditions weren't true, I added wait step to wait for 1 day,then another step to Start workflow where I called the current workflow recursively. Meaning, if the conditions aren't true have the workflow call itself again.

How does Activiti dynamic assignment of candidate user work?

There is a way to pass the candidate users dynamically to Activiti workflow as described in .
How do I pass a list of candidate users to an activiti workflow task in alfresco?
When candidateUser/candidateGroup is set for a UserTask using a variable, when is the expression evaluated ? Is the task id -> user/group persisted in database for fast query of like, list all the tasks a particular use can claim ? What table is it stored in ?
When human tasks are created there are two distinct events that fire.
Create : When the task itself is created and most of the task metadata is associated with the task.
Assign : When the task assignment is evaluated and the task is assigned to either an assignee or candidateGroup.
As such, the candidateGroup expression is evaluated during the assign phase.
This means we can easily manipulate the list of candidates based on a rule, database result or some other business logic prior to the task actually being assigned using a task listener that fires on the create phase.
Hope this helps,
G
Concerning the "What table is it stored in ?" part of your question:
Candidate start groups/users for a given task or process are stored in the ACT_IDENTITY_LINK table.

Can I schedule a workflow in CQ5?

In CQ5, there is an option to schedule page activation on a particular date. I want to be able to do the same with a workflow — that I can initiate/queue it today, but it will only start executing its steps on a specified date.
Is this possible to implement this feature via a custom workflow step, using the Workflow API? Or is there another way this could be done, e.g. using Sling Events/Scheduling?
There's a process step called the AbsoluteTimeAutoAdvancer which reads a property named absoluteTime from the WorkflowData's MetaData. This is expected to be numeric long value which represents the activation time since Epoch in milliseconds.
The trick is to set this value in the metadata. I would suggest reading
extending workflows the section entitled Saving Property Values in Workflow Metadata