Hi,
I'm trying to run the below code in an automation process, and I'm getting an error "'Checklist task' object has no attribute 'Task'". Are you able to assist with revising this accordingly?
Thank you so much!!
from System import *
import clr
clr.AddReference('System.Net.Http')
from System.Net.Http import HttpClient, StringContent
from System.Text import Encoding
clr.AddReference('System.Web.Extensions')
from System.Web.Script.Serialization import JavaScriptSerializer
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
def SendEmail(fromAddress, toAddress):
email = {
'to': toAddress,
'from': fromAddress,
'body': '<hl>Please remember to record a Notice of Settlement for this order.</hl><pre>',
# + JavaScriptSerializer().Serialize(Context.FileHeld.HeldByUser)
'subject': 'NOS required for ' + Context.EmailSubjectLine
}
js = JavaScriptSerializer()
params = js.Serialize(email)
content = StringContent(params, Encoding.UTF8, 'application/json')
client = HttpClient()
response = client.PostAsync('http://sharedapi.madisoncres.com/functions/email', content).Result
print(response)
tasks = Context.ChecklistTasks
if tasks:
for task in tasks:
if task.Task == "05. Printed and Saved to Web" and task.CompletedBy and task.CompletedBy.EmailAddress:
SendEmail('selectnotifications@madisoncres.com', task.CompletedBy.EmailAddress)
How to identify Checklist tasks in a code snippet
-
- Posts: 1382
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: How to identify Checklist tasks in a code snippet
Please repost and put Python code in a "code" block to preserve the whitespace if you have any further issue. You can use the
The ChecklistTask object does not have a "Task" property. Use the field code browser to verify the properties an object has. Perhaps you mean "task.Description"?
button to do this.The ChecklistTask object does not have a "Task" property. Use the field code browser to verify the properties an object has. Perhaps you mean "task.Description"?
Bob Richards, Senior Software Developer, SoftPro
Re: How to identify Checklist tasks in a code snippet
Okay, thank you! I got it to work with the below code snippet.
Code: Select all
from System import *
import clr
clr.AddReference('System.Net.Http')
from System.Net.Http import HttpClient, StringContent
from System.Text import Encoding
clr.AddReference('System.Web.Extensions')
from System.Web.Script.Serialization import JavaScriptSerializer
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
def SendEmail(fromAddress, toAddress):
email = {
'to': toAddress,
'from': fromAddress,
'body': '<hl>Please remember to record a Notice of Settlement for this order.</hl><pre>',
# + JavaScriptSerializer().Serialize(Context.FileHeld.HeldByUser)
'subject': 'NOS required for ' + Context.EmailSubjectLine
}
js = JavaScriptSerializer()
params = js.Serialize(email)
content = StringContent(params, Encoding.UTF8, 'application/json')
client = HttpClient()
response = client.PostAsync('{url}/functions/email', content).Result
print(response)
tasks = Context.ChecklistTasks
if tasks:
for task in tasks:
if task.Description == '05. Printed and Saved to Web' and task.CompletedBy and task.CompletedByUser.EmailAddress:
SendEmail('{email address}', task.CompletedByUser.EmailAddress)
-
- Posts: 1382
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: How to identify Checklist tasks in a code snippet
Congratulations on getting it working! Hope you don't mind but I edited your post to remove any URLs and email addresses to avoid the possibility of your services being spammed.
Thanks for posting the final product so others can use your example!
Thanks for posting the final product so others can use your example!
Bob Richards, Senior Software Developer, SoftPro