question

jansiranikrishnan-1796 avatar image
0 Votes"
jansiranikrishnan-1796 asked AnnaManzoni-2374 commented

How to retrieve analyst comments from an incident using SCSM commands?

Hi Team,

I am working on an integration project which requires me to retrieve Incident details using SMLets. I am successful in retrieving other incident details except Analyst comments. There are two relationship class available for

  1. ActionLog

  2. CommentLog

Could anyone please throw some inputs on how to retrieve the analyst comment?

Any help is highly appreciated.

Thanks,

Jansi

msc-service-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered AnnaManzoni-2374 commented

Hi @jansiranikrishnan-1796 ,

please try this to get the analyst comments of an incident:

 Import-module SMlets # Import SMLets module
 $smdefaultserver = "SCSM1" # Define SCSM Management Server
 $IRid = "IR2031" # Define Incident Record
 $IRclass=Get-SCSMclass -name System.Workitem.Incident$ # Get SCSM Incident class object
 $IRobject=Get-SCSMobject -class $IRclass -filter "ID -eq $IRid" # Get IR object
    
 # Get analyst comments of Incident
 $relIncidentAnalystComment = Get-SCSMRelationshipClass -Name System.WorkItem.TroubleTicketHasAnalystComment$
 $AnalystComments = Get-SCSMRelatedObject -SMObject $IRobject -Relationship $relIncidentAnalystComment
 $AnalystComments | Select *


If you need the user comments and/or the action log entries as well, this might help:
https://github.com/abaumgarten42/SCSM_Useful_PSscripts/blob/main/Get-IncidentComments.ps1


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hey Andreas,

Thank you so much for your response. it is working. You are like a "God" to me, always showing me inputs or directions to the solution. No words to express my gratitude.

$AnalystComments = (Get-SCSMRelatedObject -SMObject $IRobject -Relationship $relIncidentAnalystComment).comment -> i got the comments added to the incident

0 Votes 0 ·

Hi @jansiranikrishnan-1796 ,

thanks for the kind feedback.


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

0 Votes 0 ·

Thanks @ AndreasBaumgarten for your reply, I had my problem fixed by adding this code:

 Import-module SMlets # Import SMLets module
  $smdefaultserver = "SCSM1" # Define SCSM Management Server
  $IRid = "IR2031" # Define Incident Record
  $IRclass=Get-SCSMclass -name System.Workitem.Incident$ # Get SCSM Incident class object
  $IRobject=Get-SCSMobject -class $IRclass -filter "ID -eq $IRid" # Get IR object
        
  # Get analyst comments of Incident
  $relIncidentAnalystComment = Get-SCSMRelationshipClass -Name System.WorkItem.TroubleTicketHasAnalystComment$
  $AnalystComments = Get-SCSMRelatedObject -SMObject $IRobject -Relationship $relIncidentAnalystComment
  $AnalystComments | Select *

I ran into the same issues when trying to retrieve analyst comments from an incident following the ITIL books regulations


0 Votes 0 ·