Perhaps the following will give you some ideas about adding checklist items. This snippet must be set up in SPAdmin as "Every time a task is added or updated and task type if Requested then do the following: run code snippet". When the user changes a Requested Task in an order then closes it, the code below executes to create three checklist tasks. If the names already exist, they will not be added again.
Code: Select all
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
# Create a new checklist task. If an item with the same description
# already exists then it will NOT be created again.
def CreateChecklistTask(order, tasks, description, reqTask):
# If we find it already in checklist collection then items is True.
items = [t for t in order.ChecklistTasks if t.Description.lower() == description.lower()]
if items:
return
# Checklist doesn't exist already - create it.
ct = IOrder.CreateNew(order, 'ChecklistTask')
tasks.Add(ct)
ct.Description = description
ct.Status = TaskStatusType.Required
ct.AssignedTo = order.Escrow.PreCloserEscrowAssistant
ct.DueDate = reqTask.CreatedDate.AddDays(4)
# If Req task starts with magic string then create Checklist tasks
desc = Context.Description
if desc.lower().startswith('abc'):
# Helper vars.
order = Context.Root
tasks = order.Tasks
# Create three additional checklist tasks.
CreateChecklistTask(order, tasks, desc + ' - Huey', Context)
CreateChecklistTask(order, tasks, desc + ' - Dewey', Context)
CreateChecklistTask(order, tasks, desc + ' - Louie', Context)