I need to get a custom field to populate with the name of the user who published a commitment to the file. I was able to get a COR to work on a test file, but when I changed the coding around for the new context, it doesn't work. My automation process says it has completed successfully, but the field I'm trying to populate isn't filled in when I go back into the order. Am I close or should I go back to the drawing board and start from scratch again? Thanks in advance.
When a document is attached
and document name contains 'Commitment'
then do the following:
run code snippet
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
order = Context.Parent.Order
aFolder = IOrder.Attachments.GetValue(Context.Parent.Order)
publishedBy = IOrderItem.GetProperty(order, 'Publisher##')
for n in aFolder.Items:
if n.Name == 'Commitment':
publishedBy = n.LastModifiedBy
When I use the following code as a COR, my custom field populates correctly. When I post it as the code snippet in my Automation Process, it says "completed successfully", but it doesn't populate my custom field. I assume it's a Context issue, I'm just not very familiar with the Attachments Context.
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
def Publisher_Value(args):
order = args.Context.Root
publisher = IOrderItem.GetProperty(order, 'Publisher##')
docs = IOrder.Attachments.GetValue(args.Context.Root)
for n in docs.Items:
if n.Name == 'Commitment':
modUser = n.LastModifiedBy
args.Value = modUser
Publisher_Value.__name__ = 'Order_Publisher##_Value'
The problem is related to the fact that copying a property's value to string does not make that string instance an alias for the property. To set the value of a property (outside of a COR), you need to use SetProperty(). CORs effectively do Get/SetProperty() operations for you.