web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

how toloop thr all task (entitycollection.entities and check if any task that has CSU task status not equal to completed

(0) ShareShare
ReportReport
Posted on by

how toloop thr all task (entitycollection.entities and check if any task that has CSU task status not equal to completed

I have the same question (0)
  • Community Member Profile Picture
    on at

    hi

  • Suggested answer
    Ray Profile Picture
    1,537 on at

    Hi,

    I am not sure about what "CSU" task means. But I think you can loop all task by LINQ.

    As follow examples, I assumed the task status is an OptionsetValue and Completed status is 100000000 and the task status field name is taskstatus and your entitycollection variable is taskCollection.

    // assumes
    int taskCompletedStatus = 100000000;
    string statusFieldName = "taskstatus";
    EntityCollection taskCollection = new EntityCollection(); // replace this by your entitycollection
    
    // return true if there is any task status not equal completed
    bool isAnyUncompletedTask1 = taskCollection.Entities.Any(x => !x.Contains(statusFieldName) || x.GetAttributeValue(statusFieldName).Value != taskCompletedStatus);
    // return true if there is any task status not equal completed
    bool isAnyUncompletedTask2 = taskCollection.Entities.Any(x => x.GetAttributeValue(statusFieldName)?.Value != taskCompletedStatus);
    
    // also here is an example to filter task by your condition
    List taskList = taskCollection.Entities.Where(x => x.GetAttributeValue(statusFieldName)?.Value != taskCompletedStatus).ToList();

  • Verified answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    Please share your plugin code to help you on your query.

    You can look at below article on how to loop through Entity collection.

    docs.microsoft.com/.../use-queryexpression-class

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 128 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 95

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans