Thursday, November 22, 2012 11:47 AM
Unfortunately the change request does not save the close date, and I need this date to take several metrics of my changes request.
How can I create a simple powershell to save the date when I close a change request and assign it to a workflow?
Can you please help me? I never do a script powershell to update a ticket.
Thursday, November 29, 2012 5:32 PM
Maybe this example will help, this is an easy example to update a ticket:
In which field are you planning to save the close date?
Hope this helps
Friday, November 30, 2012 6:05 AM
In the Change Request class you have the ActualEndDate Property which can be set as follows:
$class = Get-SCSMClass System.Workitem.ChangeRequest$ Get-SCSMObject $class -Filter "Id -eq CR1151"|Set-SCSMObject -property ActualEndDate -value "01/11/2012"
Just replace the ID CR 1151 with your change request.
Cheers / Roman
Problem talk creates problems, solution talk creates solutions (Steve deShazer)
Friday, November 30, 2012 11:05 AM
Thanks for your reply, I need the to create an workflow that runs whenever a change request is closed.
In you code example the ID and the date is static, and I need a data and ID dynamic ,how can I put the ID,actual hour and operator dynamic in that script?
Friday, November 30, 2012 2:25 PM
you have to define these properties as "script properties" in the powershell activity.
See also this blog post about how to use variable data in your powershell workflows: http://blogs.technet.com/b/servicemanager/archive/2011/03/15/updating-a-change-request-when-activities-are-updated-using-powershell-in-a-workflow.aspx
Basically you would only need the Work item ID, based on this you should be able to retrieve any other property by querying the WI properties and relationships.
But subscribing the properties directly using the "script properties" is easier as you don't have to query them anymore...