Add Note to Task

Questions about and code samples for automation process code snippets within Select.
Post Reply
kylecrosland
Posts: 12
Joined: Thu May 04, 2017 6:28 pm

Add Note to Task

Post by kylecrosland »

Hello,

I'm trying to add a note to a task whenever the task is added to an order. The code below adds a note to the order when a task is created. How can I modify it to add the note to the task? Thanks!

Code: Select all

def AddNote():
	tasks = Context.Tasks
	for t in tasks:
		if t.Description == "Prepare Owner's Policy":
			note = IOrder.CreateNew(Context, 'Note')
			note.Text = 'this is just a test''
			note.Categories = '3'
			note.Type = NoteType.Information
			note.DisplayOnOrderOpen = False
			Context.Notes.Add(note)
	
AddNote()
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Add Note to Task

Post by BobRichards »

I created an automation rule to test the new code: "Every time a task is added or updated then do the following: run code snippet"

If one or more tasks change, Select will run this code one or more times. Each time, Select will pass you one task. This is what we mean when we say this makes the Context for the code a task.

One more thing, the only legal strings to pass to note.Categories consists of valid categories numbers separated by commas or a single category number in a string. If you do not want to set a category, set the property to None or you will get an error.

Code: Select all

from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *

# Context is 'Task'

def AddNote():
	if Context.Description == "Prepare Owner's Policy":
		note = IOrder.CreateNew(Context.Root, 'Note')
		Context.Notes.Add(note)
		note.Text = 'this is just a test: ' + str(DateTime.Now.ToString())
		note.Categories = None # or '1' or '1,2'
		note.Type = NoteType.Information
		note.DisplayOnOrderOpen = False
	
AddNote()
Bob Richards, Senior Software Developer, SoftPro
kylecrosland
Posts: 12
Joined: Thu May 04, 2017 6:28 pm

Re: Add Note to Task

Post by kylecrosland »

Perfect! Thanks, Bob!
Post Reply