Page 2 of 2

Re: Create an Attachment Folder

Posted: Sun Mar 17, 2019 10:41 pm
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'

Re: Create an Attachment Folder

Posted: Thu Mar 21, 2019 11:45 am
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.