Jump to content

Logging service request with custom field mapping - Powershell API Module

Recommended Posts


I'm trying to use the Powershell Hornbill module to log requests through the API, I can log a request but i'm unable to map the corresponding questions so the BPM can go through the required process

The request needs to have these answers in order to process properly (this is logged manually) 



When logging the call through the API no questions are shown, i have tried using the "questionfieldmap" function but think unsure of the formatting (I have only tried to add the first question at the moment). The attached snippet is what I have written

Install-Module -Name HornbillAPI
Import-Module HornbillAPI

$InstanceName = "INSTANCE"

Set-HB-Instance -Instance $InstanceName -Key $APIKey

Add-HB-Param "com.hornbill.servicemanager"
Add-HB-Param "ServiceRequests"

Add-HB-Param "summary" "Change of Hardware Test"
Add-HB-Param "description" "Change of Hardware Test"
Add-HB-Param "customerId" "andyt"
Add-HB-Param "status" "open"
Add-HB-Param "categoryId" "781"
Add-HB-Param "serviceId" "23"
Add-HB-Param "bpmName" "change-of-hardware-v3"

$QuestionFieldMap = @{question="PA or DVaaS";answer="DVaaS Machine";field_type="staticradioset";entity_type="request"} | ConvertTo-Json -compress

Add-HB-Param "QuestionFieldMap" -ParamValue $QuestionFieldMap

$response = Invoke-HB-XMLMC "apps/com.hornbill.servicemanager/ServiceRequests" "logServiceRequest"

Any advice would be appreciated

Link to comment
Share on other sites

@Andytaylor93 the questionFieldMap parameter is for when PC answers are mapped to a custom field. What you have in there is generic questions and answers in PC. For generic q and a you need to use the questions parameter. Here is an example of the JSON string for this param for having a field of type radioset with two options, and for when Option 2 has been selected during PC:

[{"form_id":"test","question":"Field 1","question_id":"field_1","answer":"Option 2","answer_value":"Option 2","field_type":"radioset","entity_type":"request","hbfield":{"question":"Field 1","field":{"id":"field_1","defLabel":"Field 1","transLabel":"x","binding":"global.test.field_1","noInvisibleValue":false,"design":{"isVisible":true,"isMandatory":false,"isReadOnly":false,"showIfEmpty":false,"extraClass":" "},"control":{"type":"radioset","options":[{"id":"Option 1","text":"Option 1 Display"},{"id":"Option 2","text":"Option 2 Display"}]},"uid":"field-1-1"},"value":"Option 2","valueName":"Option 2 Display"}}]

And this is how the field is configured in PC:



The above is a rather simplified configuration. The string (specifically the values) would be different if you have other configurations for the field, e.g. translations, default flags enabled, override flags...


Edited by Victor
Incorrect JSON
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...