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,...
Suggested Answer

On change of the state of the task I want to recheck if all the tasks of the parent case are completed and if so - update the cases's status to resolved or canceled.

(0) ShareShare
ReportReport
Posted on by

if (AllTaskReject(relatedTasks))
{
trace.Trace("check condition");
if (relatedTasks.Equals(769190003))
{
regardingCase["statuscode"] = new OptionSetValue(912450000);
regardingCase["description"] = "All task update csutaskstatus";
regardingCase["cos_csucasestatus"] = new OptionSetValue(769190006);
trace.Trace("bool 1");
}else
if (relatedTasks.Equals(769190002))
{
regardingCase["statuscode"] = new OptionSetValue(912450000);
regardingCase["description"] = "All task update csutaskstatus";
regardingCase["cos_csucasestatus"] = new OptionSetValue(769190002);

}
}


}
catch
{
throw;
}


}

public bool AllTaskReject(EntityCollection relatedTasks)
{
//check all the the task if rejected continue if on task not rejected do nothing

if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190003))
{
return true;
//reject
}else
{
if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190001))
{
return true;
//approve
}
else
{
return false;
}
}

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I keep seeing new threads for you. Help us to help you! I'm sorry but it's not clear what your code does and what's the goal you want to achieve.

  • Community Member Profile Picture
    on at

    hi i have multiple choices and this can only use for one. So my idea is to use multiple if but they throw this error all not value return

  • Community Member Profile Picture
    on at

    if (AllTaskReject(relatedTasks))

                   {

                       if (relatedTasks.Equals(769190003))

                       {

                           regardingCase["statuscode"] = new OptionSetValue(912450000);

                           regardingCase["description"] = "All task update csutaskstatus";

                           regardingCase["cos_csucasestatus"] = new OptionSetValue(769190006);

                       }

                       if (relatedTasks.Equals(769190002))

                       {

                           regardingCase["statuscode"] = new OptionSetValue(912450000);

                           regardingCase["description"] = "All task update csutaskstatus";

                           regardingCase["cos_csucasestatus"] = new OptionSetValue(769190002);

                       }

                   }

               }

               catch

               {

                   throw;

               }

           }

           public bool AllTaskReject(EntityCollection relatedTasks)

           {

               //check all the the task if rejected continue if on task not rejected do nothing

               if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190003))

               {

                  return true;

                   //reject

               }else

               {

                   if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190001))

                   {

                       return true;

                       //approve

                   }

                   else

                   {

                       return false;

                   }

               }

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi minh nhat,

    Why do not you analyse, debug, and run your logic first in the console application? Your all similar concerns will resolve automatically.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I'm sorry, but I still don't understand what's your goal is. Try to rephrase what you are trying to achieve. Let's say:

    On change of the state of the task I want to recheck if all the tasks of the parent case are completed and if so - update the cases's status to resolved or canceled.

    Your turn.

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi minh nhat,

    Andrew Butenko is the boss. He was also helping me a lot whenever I had stuck. Andrew Butenko, It is appreciated.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Community Member Profile Picture
    on at

    yes and its only have 2 choices

    i am thinking about this

    if (AllTaskReject(relatedTasks))                

                   {

                       trace.Trace("check condition");

                       if (relatedTasks.Equals(769190003))

                       {

                           regardingCase["statuscode"] = new OptionSetValue(912450000);

                           regardingCase["description"] = "All task update csutaskstatus";

                           regardingCase["cos_csucasestatus"] = new OptionSetValue(769190006);

                           trace.Trace("bool 1");

                       }else

                       if (relatedTasks.Equals(769190002))

                       {

                           regardingCase["statuscode"] = new OptionSetValue(912450000);

                           regardingCase["description"] = "All task update csutaskstatus";

                           regardingCase["cos_csucasestatus"] = new OptionSetValue(769190002);

                       }

                   }

               }

               catch

               {

                   throw;

               }

           }

           public bool AllTaskReject(EntityCollection relatedTasks)

           {

               //check all the the task if rejected continue if on task not rejected do nothing

               if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190003))

               {

                  return true;

                   //reject

               }else

               {

                   if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190001))

                   {

                       return true;

                       //approve

                   }

                   else

                   {

                       return false;

                   }

               }

  • Community Member Profile Picture
    on at

    hi thanks that what i need

  • Community Member Profile Picture
    on at

    hi can some one know what wrong with this code

  • Community Member Profile Picture
    on at

    On change of the state of the task I want to recheck if all the tasks of the parent case are completed and if so - update the cases's status to resolved or canceled.

    Suggested Answer

    if (AllTaskReject(relatedTasks))
    {
    trace.Trace("check condition");
    if (relatedTasks.Equals(769190003))
    {
    regardingCase["statuscode"] = new OptionSetValue(912450000);
    regardingCase["description"] = "All task update csutaskstatus";
    regardingCase["cos_csucasestatus"] = new OptionSetValue(769190006);
    trace.Trace("bool 1");
    }else
    if (relatedTasks.Equals(769190002))
    {
    regardingCase["statuscode"] = new OptionSetValue(912450000);
    regardingCase["description"] = "All task update csutaskstatus";
    regardingCase["cos_csucasestatus"] = new OptionSetValue(769190002);

    }
    }

    }
    catch
    {
    throw;
    }


    }

    public bool AllTaskReject(EntityCollection relatedTasks)
    {
    //check all the the task if rejected continue if on task not rejected do nothing

    if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190003))
    {
    return true;
    //reject
    }else
    {
    if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190001))
    {
    return true;
    //approve
    }
    else
    {
    return false;
    }
    }

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 87 Most Valuable Professional

#2
11manish Profile Picture

11manish 69 Super User 2026 Season 2

#3
Syed Aqib Raza Profile Picture

Syed Aqib Raza 48

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans