Creating a new parent incident after the time limit for the current parent is reached (PowerShell)

Rod25
Tera Expert

Hello,

 

I was tasked with creating parent/child relationships using rest api calls.  I was able to achieve this without issue.  However, one of the requirements is for the parent to only be used for a set number of hours.  Once the time limit has been reached, I have to create a new parent.  I'm able to get the open_at time from the incident table.  I need to manipulate it by adding 2 hours to the open_at time and comparing that time with the current time.  From there, I'll need to use that condition along with some other factors to determine if a new parent should be created.  Has this been done before?  Is this even possible?

 

"expected_start": "",
      "opened_at": "2023-12-20 15:40:00",
      "work_end": "",
      "caller_id": {

 

$incidentOpenTime = $response.result.open_at

$currentTime = Get-Date

2 ACCEPTED SOLUTIONS

Amit Verma
Kilo Patron
Kilo Patron

Hi @Rod25 

 

You can use below PowerShell logic to achieve this :

 

## Sample Value for incident open time##
[datetime]$incidentOpenTime = '2023-12-21 15:40:00'

$incidentOpenTime = $incidentOpenTime.AddHours(2)

$currentTime = Get-Date

## If Current time is greater than incident open time
if($incidentOpenTime -ge $currentTime)
{
    ## Do the required actions
}
else{
## Do whatever required
}

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

Rod25
Tera Expert

Thank again for your help @Amit Verma.  I was able to plug in what you provided and get the desired outcome. 😊

View solution in original post

2 REPLIES 2

Amit Verma
Kilo Patron
Kilo Patron

Hi @Rod25 

 

You can use below PowerShell logic to achieve this :

 

## Sample Value for incident open time##
[datetime]$incidentOpenTime = '2023-12-21 15:40:00'

$incidentOpenTime = $incidentOpenTime.AddHours(2)

$currentTime = Get-Date

## If Current time is greater than incident open time
if($incidentOpenTime -ge $currentTime)
{
    ## Do the required actions
}
else{
## Do whatever required
}

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Rod25
Tera Expert

Thank again for your help @Amit Verma.  I was able to plug in what you provided and get the desired outcome. 😊