I'm trying to set up a trigger that will fill in a date automatically based on a status change in the ticket (to permit a scheduled event to be run against that date).
I have created the following statuses (Internal Name | Name):
PendingCity | Pending City Response
PendingVendor | Pending Vendor Response
I have created a column in the Tickets list called PendingDateSet
I can successfully fill this column with any single bit of existing date information ({{Ticket.Modified}}, for example).
I want to put a value of, essentially, Today()+3 into that field.
The following do not work (the trigger fires, gets a true result, and it says the field is set but it obviously isn't):
Today()+3
AddDays(Today(),3)
AddDays(Date([Ticket.Modified]),3)
AddDays({{Ticket.Modified}},3)
Date([Ticket.Modified])
It looks like the functions don't work in the triggers at all, unless I have something not configured correctly for the column (Date and Time column type, I've tried with Date Only and with Date and Time).
Just for the sake of seeing if it would work at all, I tried Today() as the value to set the date field to, and it didn't work either.
What do I need to put in the Action of the trigger to set a date field to a date in the future?
Currently, you can't do something like that directly, but you can start a workflow in your trigger which will automatically set your Date field to the current date plus 3 days in your case:
Here is how to do it in Sharepoint Designer 2013:
Firstly you should create a list workflow which will be connected to the Tickets list
Then in the workflow, for your specific case you should add the following actions:
Where you should change 'Due date' to your custom column in the list.
After you published the workflow, now you can choose it in the trigger:
Hm. OK, not quite. The workflow runs on every item in the list, not just the item being edited, and seemingly all the time (I can refresh the ticket view and the date that it sets is constantly being updated. I have the start options set to "allow this workflow to be manually started" and have turned off automatically when an item is created or changed.
I tried another way by creating a calculated column, which I can get to figure out the date three days in the future - but it's not available as a field to set a condition on a scheduled task (or a trigger). Why can't I see the calculated column?
I still suggest you to use workflow to set fields in the ticket.
To restrict the trigger from being constantly running and updating, please, add the following condition:
Where you should change [Ticket.DueDate] to your custom field.
And also don't forget to check 'Active' box, as I can see in your screenshot of the trigger it is unchecked.