How to get Task Status from tasks in Checklist and Request list.

Discussions related to custom development with Select.
Post Reply
jturek
Posts: 14
Joined: Fri Jul 20, 2018 6:17 pm

How to get Task Status from tasks in Checklist and Request list.

Post by jturek »

Hi Team,

The requirement is to get task status of some of tasks in Checklist and Requested list.
For this written the below code and gets the task list. Now I have to compare the task description and get its Status.

Code: Select all


                            IOrder order = os.OpenOrder(search, true);

                            // Get list of tasks and add all task types to it.
                            IList tasks = (IList)order.GetProperty("Tasks");

                            // Cast to dynamic to make TaskList handling easier.
                            dynamic taskList = (dynamic)tasks;                            

                            Dictionary<string, string> CheckAndRequestList = new Dictionary<string, string>();
                            CheckAndRequestList.Add("210 Seller Figures", "");
                            CheckAndRequestList.Add("220 Lender Figures", "");
                            CheckAndRequestList.Add("110 Proceeds", "");
                            CheckAndRequestList.Add("ALTA Settalment Statement", "");

                         
                            foreach (dynamic taskItem in taskList)
                            {
                                string taskName = CheckAndRequestList.Keys.FirstOrDefault(s => s == taskItem.Description.ToString());
                                if (CheckAndRequestList.ContainsKey(taskName))
                                {
                                   // Get the task status here
                                    CheckAndRequestList[taskName] = <<How we can get task status here>>;
                                }
                                
                            }
Please suggest for the same.
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to get Task Status from tasks in Checklist and Request list.

Post by BobRichards »

Have you tried putting in a breakpoint inside your tasklist loop and seeing what's there? Given the dynamic nature of model, it is a valuable technique to learn.

In addition, you can navigate to the "Order.Tasks" object in the Field Code Browser in the Select UI. (This is the base class from which ChecklistTask and RequestedTask inherit.) It has a property named Status that is of type TaskStatusType. This type is an enum that is in our public libraries and is in the SDK documentation. This enables you to do operations like:

Code: Select all

// 'theTask' is an order Task, ChecklistTask, or RequiredTask.

TaskStatusType type = (TaskStatusType )theTask.GetProperty("Status");
if (type == TaskStatusType.Required)
{
    ...
} 
Be aware that there are behavior differences between the different types of tasks. For instance, a ChecklistTask Status cannot be set to 'Received'.
Bob Richards, Senior Software Developer, SoftPro
jturek
Posts: 14
Joined: Fri Jul 20, 2018 6:17 pm

Re: How to get Task Status from tasks in Checklist and Request list.

Post by jturek »

Now successfully received the task status of given task names(Description).
Is this right approach to fetch the task status of given task name ?

Code: Select all

			    // Open Order.
                            IOrder order = os.OpenOrder(search, true);

                            // Get list of tasks and add all task types to it.
                            IList tasks = (IList)order.GetProperty("Tasks");

                            // Get the CheckList and Request list  task status                            
                            var RequiredTaskList = ConfigurationManager.AppSettings.AllKeys.Where(k => k.StartsWith("TaskList.")).ToDictionary(k => k.Split('.')					 
  [1], v => ConfigurationManager.AppSettings[v]);

                            foreach (var itemKey in RequiredTaskList.Keys.ToList())
                            {
                                dynamic task = ((IEnumerable<dynamic>)tasks).Where(x => x.Description == itemKey).FirstOrDefault();
                                if (task != null)
                                    objSoftProOrderEntity.CheckAndRequestList[itemKey] = task.Status.ToString();
                            }
This gives output as below
SoftPro Task Status.png
SoftPro Task Status.png (70.55 KiB) Viewed 1233 times
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to get Task Status from tasks in Checklist and Request list.

Post by BobRichards »

The task related lines look fine.
Bob Richards, Senior Software Developer, SoftPro
Post Reply