Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
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.

Posted on by Microsoft Employee

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
    Community Member Microsoft Employee on at
    how can i add more if else

    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;
    }
    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: i want to if for multiple choice plugin

    hi can some one know what wrong with this code

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: i want to if for multiple choice plugin

    hi thanks that what i need

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: i want to if for multiple choice plugin

    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;

                   }

               }

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Moderator on at
    RE: i want to if for multiple choice plugin

    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/.../

  • a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: i want to if for multiple choice plugin

    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
    Abdul Wahab 12,070 Moderator on at
    RE: i want to if for multiple choice plugin

    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/.../

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: i want to if for multiple choice plugin

    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;

                   }

               }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: i want to if for multiple choice plugin

    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

  • a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: i want to if for multiple choice plugin

    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.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans