- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 08:22 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2023 12:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2023 06:07 AM
Thank again for your help @Amit Verma. I was able to plug in what you provided and get the desired outcome. 😊
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2023 12:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2023 06:07 AM
Thank again for your help @Amit Verma. I was able to plug in what you provided and get the desired outcome. 😊