Change request close date
-
Thursday, November 22, 2012 11:47 AM
Hello All,
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.
Regards
All Replies
-
Thursday, November 29, 2012 5:32 PM
Hello JPFG,
Maybe this example will help, this is an easy example to update a ticket:
http://blogs.technet.com/b/servicemanager/archive/2011/02/03/breaking-all-the-rules-part-2-forcing-a-change-request-status-from-closed-to-completed.aspxIn which field are you planning to save the close date?
Hope this helps
-
Friday, November 30, 2012 6:05 AM
Hi !
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)
- Proposed As Answer by Expiscornovus Friday, November 30, 2012 9:13 AM
- Marked As Answer by Andreas BaumgartenMVP, Moderator Sunday, January 13, 2013 4:34 PM
-
Friday, November 30, 2012 11:05 AM
Hello Roman,
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?
Regards,
-
Friday, November 30, 2012 2:25 PM
Hi,
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...
Alex
- Proposed As Answer by Andreas BaumgartenMVP, Moderator Sunday, January 13, 2013 4:34 PM
- Marked As Answer by Andreas BaumgartenMVP, Moderator Sunday, January 13, 2013 4:34 PM

