Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Change task #103

Closed
MorningsWait opened this issue Nov 18, 2019 · 14 comments · Fixed by #196
Closed

Create Change task #103

MorningsWait opened this issue Nov 18, 2019 · 14 comments · Fixed by #196
Assignees

Comments

@MorningsWait
Copy link

Thanks team on working on my last request (Create change request), I must be more demanding, if possible can you please create same for change tasks as well

@Rick-2CA Rick-2CA self-assigned this Dec 16, 2019
@MorningsWait
Copy link
Author

MorningsWait commented Dec 25, 2019

Hello I tried and changed the config can you please check, it is working for me change table name to 'change_task'
i am not sure how to attach the files here

@Chandresh88
Copy link

Hello Team,

I am new to github as well as to programming, Do we have any template to create the change task in service now?

@wwwb0n3zcom
Copy link

What about just Get-ServiceNowChangeTask ?

I don't see any method to get information about CTASK items. Change requests are prefixed with CHG for the number. Change tasks are prefixed CTASK for the number.

@wwwb0n3zcom
Copy link

What about just Get-ServiceNowChangeTask ?

I don't see any method to get information about CTASK items. Change requests are prefixed with CHG for the number. Change tasks are prefixed CTASK for the number.

So I believe I figured out some bit of RestAPI with a proof of concept to "Get-ServiceNowChangeTask" (change XXX to your environment):

#CTASK number
$num = "CTASKXXX"

#Set variable for credentials
If (-not($cred))
{$cred = Get-Credential}

#Specify endpoint uri for ServiceNow
$uri = "https://XXX.service-now.com/api/now/table/change_task?sysparm_query=number=$Num"

#Specify http method
$method = "get"

#Send http request
$output = (invoke-restmethod -method $method -uri $uri -ContentType "application/json" -Credential $cred).Result

#Print Response
$output

@gdbarron
Copy link
Collaborator

gdbarron commented May 28, 2021

Get-ServiceNowRecord can be used to get table info on any table if there isn't a specific function to do so. For example, Get-ServiceNowRecord -Table change_task -Filter @('number', '-eq', $num)

@gdbarron
Copy link
Collaborator

I'd like to get away from having a different Get- function for every table. For 1, there are hundreds of tables and it feels like a losing battle. And 2, the only difference between each function is the table name. I'd like to use Get-ServiceNowRecord with a tab-ahead perhaps or something similar for -Table to make it easier for folks and have everyone use that 1 function. Thoughts?

@gdbarron gdbarron assigned gdbarron and unassigned Rick-2CA Jun 8, 2021
@wwwb0n3zcom
Copy link

Thank you @gdbarron - I have converted my scripts to use this new logic Get-ServiceNowRecord -Table instead.

@wwwb0n3zcom
Copy link

This should be marked as closed or resolved.

@gdbarron
Copy link
Collaborator

gdbarron commented Sep 7, 2021

To be fair to @MorningsWait and @Chandresh88, the original intent of this issue was to 'create' a change task, not 'get'. I should have suggested we create a new one for 'get', but failed to do so. I'll keep this open until the 'create' aspect is complete.

@wwwb0n3zcom
Copy link

wwwb0n3zcom commented Sep 10, 2021

Hello I tried and changed the config can you please check, it is working for me change table name to 'change_task'
i am not sure how to attach the files here

@Chandresh88 - I just used the following to create a CTASK and it worked fine. Yes, I could have put the values within the $Params, but for legibility with long values - this is preferred.

#Variables
$short_description = 'Short Description here'
$description = 'Description here'
$assignment_group = 'assignment group here'
$assigned_to = 'assigned to here'
$requested_by = 'requested by here'

#Splatting the variables to the Cmdlet
$Params = @{
  short_description           = $short_description
  description                 = $description
  assignment_group            = $assignment_group
  assigned_to                 = $assigned_to
  requested_by                = $requested_by
}

$Record = New-ServiceNowRecord -Table 'Change Task' -Values $Params -PassThru
Write-Output -InputObject $Record.number

@MorningsWait
Copy link
Author

I believe this still needs to be worked on as well as we can do all 3 tasks get/modify/Delete

@gdbarron
Copy link
Collaborator

@MorningsWait, do you have a suggestion as to which change task fields are most used so we can include them in a New-ServiceNowChangeTask? According to the dev instance, looks like short description and description are required and I assume we'll need the change request number. What else are you thinking?

@gdbarron
Copy link
Collaborator

@MorningsWait following up...

@MorningsWait
Copy link
Author

I am sorry for responding late, Short Description, Description, Parent CHG, Assignment Group & Assigned To the

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants