from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
# Get the root order from the context
order = Context.Root
# Check if the address starts with "0"
for prop in Order.Properties:
if prop.Address.Address1.startswith("0"):
# Create a new note
note = Iorder.CreateNew(Context, 'Note')
note.Text = 'Vacant Land Alert'
note.Type = NoteType.Critical
note.DisplayOnOrderOpen = True
Context.Notes.Add(note)
I cannot get it to add the note only on files that the address {{Order.Properties.Address.Address1}} startwith 0
It adds a note to every file or any file that contains a 0 anywhere in the address.
Can someone help me fix my code snippet?
Adding a note to files that have a property address that startswith 0
Re: Adding a note to files that have a property address that startswith 0
It seems to be working just fine for me, once I fixed a couple of minor typos in your example. Specifically replacing the capital O with lowercase in the for loop, and capitalizing the O in the Iorder.CreateNew
After that, I tested with the following addresses:
Main 0
0 Main
123 Main
and only the '0 Main' entry triggered the creation of the note.
Code: Select all
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
# Get the root order from the context
order = Context.Root
# Check if the address starts with "0"
for prop in order.Properties:
if prop.Address.Address1.startswith("0"):
# Create a new note
note = IOrder.CreateNew(Context, 'Note')
note.Text = 'Vacant Land Alert'
note.Type = NoteType.Critical
note.DisplayOnOrderOpen = True
Context.Notes.Add(note)
Main 0
0 Main
123 Main
and only the '0 Main' entry triggered the creation of the note.
Vlad Mrvichin, Senior Software Developer, Custom Dev, SoftPro
Re: Adding a note to files that have a property address that startswith 0
Thank you for your reply.
Can you try the address like 120 Main Street?
Mine is still triggering when the 0 is anywhere in the number sequence.
Actually, will it run on every file, but just not add the note if it isn't true? Sorry, I am fairly new to code snippets.
Can you try the address like 120 Main Street?
Mine is still triggering when the 0 is anywhere in the number sequence.
Actually, will it run on every file, but just not add the note if it isn't true? Sorry, I am fairly new to code snippets.
Re: Adding a note to files that have a property address that startswith 0
120 Main Street did not create an order note for me.
This is correct. Automations trigger based on what you have set in the 'When' section of the Automation Process Wizard. Where do you have this code snippet? If it's all in the Then section, then yes the automation will run every time You can split it up into 2 snippets. The first in the If section to check to see if the property's address starts with a 0, then the Then section could be the one that adds the note. This will then only run the automation when there is a property in the order whos address starts with a 0
Vlad Mrvichin, Senior Software Developer, Custom Dev, SoftPro
Re: Adding a note to files that have a property address that startswith 0
Perfect!! I completely understand. Thank you so much for your help! I am going to reorganize.