Get Value for Requested tasks due date

Questions about and code samples for automation process code snippets within Select.
Post Reply
tamar
Posts: 9
Joined: Wed Dec 14, 2022 4:52 pm

Get Value for Requested tasks due date

Post by tamar »

I try to evaluate via Automation Code Snippet the value of requested task due date.
(see attached.)
meanwhile with no success.
How can I do it?
Thanks in advance!
Attachments
The required field.
The required field.
dueDate.PNG (34.14 KiB) Viewed 26143 times
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Get Value for Requested tasks due date

Post by BobRichards »

Here is an example of reading that field and displaying the value in the Errors and Windows panel.

Code: Select all

def RequestedTask_RequestDueDate_Validate(args):
    task = args.Context
    args.RaiseInformation(str(task.RequestDueDate))
2023-01-12_10-33-03.png
2023-01-12_10-33-03.png (12.76 KiB) Viewed 26139 times
Bob Richards, Senior Software Developer, SoftPro
tamar
Posts: 9
Joined: Wed Dec 14, 2022 4:52 pm

Re: Get Value for Requested tasks due date

Post by tamar »

Thank you so much!
But I don't want to create a validation, I want to do something like this:
Each time an order is saved, and the task.requestDueDate field is updated, I want to send a webhook to my server with the new value.
This is what I tried:
1. I went to SPAdmin > Automation > New process.
2. I chose "Each time an order is saved"
3. I added a filter: "The order has a task with specific field...". see attached.
4. I wrote a code snippet, but I don't know how to get the value of requestedDueDate.

def SendWebhook():
order = Context.Root
orderNum = IOrderItem.GetProperty(Context, 'Number')
RequestDueDate = ????? //here I need your help how to do it.

// Send the data to my server, I know how to do it.

SendWebhook()

Thanks!
Attachments
code snippet.PNG
code snippet.PNG (31.94 KiB) Viewed 26128 times
Capture.PNG
Capture.PNG (16.25 KiB) Viewed 26128 times
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Get Value for Requested tasks due date

Post by BobRichards »

The problem with using a condition where you monitor a property for changes is that if the property exists on an item in a collection you won't be able to determine which item was changed - in fact multiple items could have changed. In your use (changes in tasks), you should use the "Everytime a task is added or updated" so you can know which task was changed is you have more than one.
2023-01-18_17-51-44.png
2023-01-18_17-51-44.png (4.64 KiB) Viewed 26117 times
This code snippet can be used as an example of how to get the RequestedDueDate. Your context will be the Requested Task that has the update property. The really nice thing about this technique is if more than one task has a change, the Automation Snippet code will run once for each changed task.

Code: Select all

from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *

# Context is the modified task.
order = Context.Root

# Write modified RequestDueDate to order Project.
order.Project = str(Context.RequestDueDate)
Bob Richards, Senior Software Developer, SoftPro
Post Reply