I'm writing a Dynamics CRM 2015 plugin, that is triggered by the sdk message step "assign of Task" and runs asynchronously.
In Execute(IServiceProvider serviceProvider)
method, I want to search for other currently running system jobs, using a QueryExpression
:
QueryExpression systemjobq = new QueryExpression
{
EntityName = "asyncoperation",
ColumnSet = new ColumnSet("name", "createdon", "completedon", "regardingobjectid", "asyncoperationid", "startedon", "messagename", "statuscode"),
Criteria = new FilterExpression
{
Conditions = {
new ConditionExpression
{
AttributeName = "name",
Operator = ConditionOperator.Equal,
Values = { "My system jobs name" }
}
}
}
};
Because I don't want to find "myself" - the currently running system job - I need to find out the asyncoperationid
of the currently running system job that executes my plugin, so I can include it in my search query expression.
How can I find out the asyncoperationid
of the currently running system job?