Create an Attachment Folder

Questions about and code samples for automation process code snippets within Select.
Kolinski
Posts: 12
Joined: Sat Oct 20, 2018 12:21 am

Re: Create an Attachment Folder

Post by Kolinski »

Here's my process:

First time an order is saved
and owning profile is under 'Default\Test & Training'
and Order.TitleCompanies[0].Name is populated
then do the following
run code snippet

and just to be sure here's my code snippet again:

Code: Select all

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'
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Create an Attachment Folder

Post by BobRichards »

(Sorry to take so long to get back to you.)

In the example you gave, the context will not be an attachment item. Since it begins with "First time an order is saved", the context will be an order. The When you need to use to get an attachment item as context is "Document is attached".

Be sure to check out our online help by pressing F1 after you click the "New Process" button.
Bob Richards, Senior Software Developer, SoftPro
Post Reply