Adding notes to a task

Questions about and code samples for automation process code snippets within Select.
Post Reply
parker
Posts: 7
Joined: Fri Jan 22, 2021 11:29 am

Adding notes to a task

Post by parker »

Is it possible to change the context during an automation running so that a task note can be added using on properties from the order (or contacts) context?

I have an automation that runs when a task us updated, code snippet below, but if I try to add a note value for items outside the task context it fails as undefined. Specifically we were looking for order contact name/cell numbers to add to the note.

I've used the formula editor in the note's to confirm the needed notes manually but wanted to automate the process & can add standard text/strings but alternatively would it be possible to pass a formula through the note.Text? Like -

Code: Select all

Value = {{Order.Buyers.Name}}

Code Snippet for automation:

Code: Select all

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

def AddNote():
	if Context.Description == "Buyer Approval":
		note = IOrder.CreateNew(Context.Root, 'Note')
		Context.Notes.Add(note)
		note.Text = #ex: If I wanted to pull buyers name/cell as the note
		note.Categories = None
		note.Type = NoteType.Information
		note.DisplayOnOrderOpen = True

AddNote()
PaulMcCullough
Posts: 23
Joined: Wed Jul 12, 2023 11:29 am

Re: Adding notes to a task

Post by PaulMcCullough »

Yes, Context.Root is used to access the order that the Task belongs to. From there you can access properties on the order. An example is below.

Code: Select all

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

def AddNote():
	if Context.Description == "Buyer Approval":
		note = IOrder.CreateNew(Context.Root, 'Note')
		Context.Notes.Add(note)
		order = Context.Root
		buyer = order.Buyers[0]
		note.Text = buyer.Name + " Cell: " + buyer.MainPerson.Cell
		note.Categories = None
		note.Type = NoteType.Information
		note.DisplayOnOrderOpen = True

AddNote()
Post Reply