inserting to custom_fields when creating ticket

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Firmbyte
Posts: 11
Joined: 07 Feb 2017, 17:23

inserting to custom_fields when creating ticket

Post by Firmbyte »

I'm trying to insert to fields in custom_fields in a ticket. I'll have to insert/update all the custom_fields, but specifically, in the ticket there is a field called " CSG Director" and I want to insert when I create a new ticket and update the value if existing.
How I'm trying to do it now is erroring. I can see that the value is not part of the $custom but can't figure out how I should be inserting that.

Code: Select all

The property 'Value' cannot be found on this object. Verify that the property exists and can be set.
I've also looked at using "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1pi_soap_mantisconnect_php_wsdl.CustomFieldValueForIssueData" but not getting anywhere there either.

Any help gratefully received!

Code: Select all

ID  Name                           value
--  ----                           -----
248 Control ID
145 CSG Director                   Bloggs
200 Complexity
279 Platform

Code: Select all

$mantis = New-WebServiceProxy -Uri "http://tickets.mycompany.com/api/soap/mantisconnect.php?wsdl"
$ticketinfo = $mantis.mc_issue_get($($Sec.Username),$($Sec.Password),$ticket)
$ticketUpdate = $ticketinfo
$Custom = New-Object "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3pi_soap_mantisconnect_php_wsdl.ObjectRef"
$Custom.Value = 'ibarnetson' 
$Custom.id = 145
$ticketUpdate.custom_fields = $Custom
$mantis.mc_issue_update($($Sec.Username),$($Sec.Password),$ticket,$ticketUpdate) 
Firmbyte
Posts: 11
Joined: 07 Feb 2017, 17:23

Re: inserting to custom_fields when creating ticket

Post by Firmbyte »

I got it cracked, not pretty, but does the job.

Code: Select all


$mantis = New-WebServiceProxy -Uri "http://ticketsdemo2.empyreanbenefits.com/api/soap/mantisconnect.php?wsdl"
$issue  = New-Object ($mantis.GetType().Namespace + ".issuedata")
$project = New-Object ($mantis.GetType().Namespace + ".ObjectRef")
$project.id = $ProjectId
$project.name = $ProjectName
$Reporter = New-Object ($mantis.GetType().Namespace + ".AccountData")
$Reporter.name = $ReporterName
$Handler = New-Object ($mantis.GetType().Namespace + ".AccountData")
$Handler.name = $HandlerName
$Custom = New-Object ($mantis.GetType().Namespace + ".ObjectRef")
$Custom.id = 145
$CustomFields = New-Object ($mantis.GetType().Namespace + ".CustomFieldValueForIssueData")
$CustomFields.field = $Custom
$CustomFields.value = 'Other'
$issue.custom_fields = $CustomFields
$issue.project = $project
$issue.Reporter = $Reporter
$issue.Handler = $Handler
$issue.summary = $summary 
$issue.description = $description 
$issue.category = $category 
$response = $mantis.mc_issue_add(($Sec.Username),$($Sec.Password),$issue)
Return $response 

Post Reply