Skip to main content

Notifications

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

Posted on by Microsoft Employee

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

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: how toloop thr all task (entitycollection.entities and check if any task that has CSU task status not equal to completed

    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

  • Suggested answer
    Ray Profile Picture
    Ray 1,505 on at
    RE: how toloop thr all task (entitycollection.entities and check if any task that has CSU task status not equal to completed

    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();

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how toloop thr all task (entitycollection.entities and check if any task that has CSU task status not equal to completed

    hi

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans