In Automation, if I don't have an Attachment Folder, I would like to create it. I'm doing this when a Document is Added. I'm struggling with how to Create Folder, any help would be appreciated. I'm getting "unexpected token '<newline>'" as the reason my process fails.
# Context ( IAttachmentItem) is the document that was attached to order!
# Get top level attachment folder at "\{OrderNumber}\Attachments"
topFolder = IOrder.Attachments.GetValue(Context.Parent.Order)
findFolder = [a for a in topFolder.Items if a.Name == 'FolderName']
if findFolder:
# Found the target folder
destFolder = findFolder[0]
else
# Create Folder at "\{OrderNumber}\Attachments\{folder}"
newFolder = topFolder.NewFolder()
newFolder.Name = 'FolderName'
Thank you, still learning Python and the colon was missing in the handout I got at the user group a couple of years ago (Custom Order Rules for SoftPro Select).
Please submit your code and make sure the automation context is IAttachmentItem. Please put your code inside code tags ("</>" button) so it will be properly spaced and readable.
I'm not sure how to set the automation context. I know just enough to cause trouble but not enough to always know what I'm doing. I've tried to search the forum and piece together other code or use ones that I currently have running but no luck.
Here's what I was using to get the error in my last post:
# Context ( IAttachmentItem) is the document that was attached to order!
# Get top level attachment folder at "\{OrderNumber}\Attachments"
topFolder = IOrder.Attachments.GetValue(Context.Parent.Order)
findFolder = [a for a in topFolder.Items if a.Name == 'FolderName']
if findFolder:
# Found the target folder
destFolder = findFolder[0]
else:
# Create Folder at "\{OrderNumber}\Attachments\{folder}"
newFolder = topFolder.NewFolder()
newFolder.Name = 'FolderName'
As always your help is appreciated and if there is any place you can direct me to learn more I'd appreciate that as well!
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
# Add the rest of the Python code below...
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
# Context ( IAttachmentItem) is the document that was attached to order!
# Get top level attachment folder at "\{OrderNumber}\Attachments"
topFolder = IOrder.Attachments.GetValue(Context.Parent.Order)
findFolder = [a for a in topFolder.Items if a.Name == 'FolderName']
if findFolder:
# Found the target folder
destFolder = findFolder[0]
else:
# Create Folder at "\{OrderNumber}\Attachments\{folder}"
newFolder = topFolder.NewFolder()
newFolder.Name = 'FolderName'
I've attempted to steal some coding from the previous post regarding adding attachments to folders but have had no luck. Thank you