Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 4 Check TaskState

$
0
0

Hi 

I have a checkbox. If checked it should complete the task if it is currently open and if unchecked it should open the task if it is currently completed.

I've got it working to complete a task which is currently open. But it doesn't work as expected to Open a task which is currently completed.
I does work if I remove my condition check before opening the task, as I commented in the code below.

Any help?

        if (activeCB != null && activeCB.Checked)
        {
            /* If checked, complete the task if it is currrently open */
            if (objtask.TaskState == TaskState.Open)
            {
                objtask.TaskState = TaskState.Completed;
                objtask.TaskStatus = 5;
            }
        }
        else
        {
            /* If unchecked, open the task if it is currrently completed */
            if (objtask.TaskState == TaskState.Completed)  //This does work when I remove this condition or if I change it to "if (objtask.TaskState == TaskState.Open)". Even though the task is completed when I check in CRM
            {
                objtask.TaskState = 0;
                objtask.TaskStatus = 2;
            }
        }
        service.Execute(objtask);


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>