The SCN_Update_1IM_ticket_status_to_ServiceNow process is responsible for constructing the response for ServiceNow update. This response is then sent to the ServiceNow end, through the process task UpdateServiceNowStatus. This task has a parameter RequestBody that takes the value from the preceding step, in the process, which calls the script SCN_GetOrderValueStatus that constructs the response. Below is the script with an example on how the script can be modified.
#If Not SCRIPTDEBUGGER
References Newtonsoft.Json.dll
#End If
'This script gets the OrderState value status from the PersonWantsOrg table with reference of the UID_PWO sent from the calling step
'Dieses Skript ruft den OrderState-Wertstatus aus der Tabelle "PersonWantsOrg" mit der Referenz der UID_PWO ab, die vom aufrufenden Schritt gesendet wurde
'On the basis of the OrderState value the necessary response is generated as explained in this script further on
'Auf der Grundlage des OrderState-Werts wird die erforderliche Antwort generiert, wie in diesem Skript weiter erläutert
Public Overridable Function SCN_GetOrderValueStatus(ByVal UID_PWO As String) As String
Dim PWO As ISingleDbObject = Connection.CreateSingle("PersonWantsOrg", UID_PWO)
Dim responseBodyStr As String = ""
Dim orderstate As String = PWO.GetValue("OrderState").String
Dim requestBody As Newtonsoft.Json.Linq.JObject = New Newtonsoft.Json.Linq.JObject()
'The Request JSON for the response will have to constructed based on the value of the OrderState in OneIM and
'the corresponding field values that are configured on the ServiceNow end.
'Der Anforderungs-JSON für die Antwort muss basierend auf dem Wert des OrderState in One Identity Manager und
'den entsprechenden Feldwerten erstellt werden, die auf dem ServiceNow-Ende konfiguriert sind.
'To add any more fiels to the request JSON, add it in the format, requestBody.Add("<fieldname>","<Value>")
'Um der Anfrage JSON weitere Felder hinzuzufügen, fügen Sie sie im Format requestBody.Add ("<Feldname>", "<Wert>") hinzu.
'Example: requestBody.Add("close_code","Closed/Resolved by Caller")
'Beispiel: requestBody.Add ("close_code", "Closed / Resolved by Caller")
Select orderState
Case "Assigned"
requestBody.Add("close_code","Closed/Resolved by Caller")
requestBody.Add("state","7")
requestBody.Add("close_notes",PWO.GetValue("ReasonHead").String)
responseBodyStr = requestBody.ToString()
Case "Granted"
requestBody.Add("state","2")
responseBodyStr = requestBody.ToString()
Case "Dismissed"
requestBody.Add("close_code","Closed/Resolved by Caller")
requestBody.Add("state","7")
requestBody.Add("close_notes",PWO.GetValue("ReasonHead").String)
responseBodyStr = requestBody.ToString()
Case "OrderProduct"
requestBody.Add("state","2")
responseBodyStr = requestBody.ToString()
Case "Aborted"
requestBody.Add("close_code","Closed/Resolved by Caller")
requestBody.Add("state","7")
responseBodyStr = requestBody.ToString()
Case Else
responseBodyStr = ""
End Select
Return responseBodyStr
End Function
In the script, the Cases sections contain the responses for various OrderState values of the PersonWantsOrg entries.
For instance:
Case "Assigned"
requestBody.Add("close_code","Closed/Resolved by Caller")
requestBody.Add("state","7")
requestBody.Add("close_notes",PWO.GetValue("ReasonHead").String)
responseBodyStr = requestBody.ToString()
Here, the variable requestBody contains the request that is to be sent to ServiceNow. In this case, we are add the ServiceNow fields close_code, state, close_notes. These fields are mandatory for any ticket to be closed on ServiceNow for resolution. More fields can be added with the requestBody before the statement responseBodyStr = requestBody.ToString().
- Syntax to add more fields: requestBody.Add(“<ServiceNow field name>”,”<Value>”)
- Example: requestBody.Add(“resoved_by”,$DisplayPersonHead$)
Here $DisplayPersonHead$ is the value of the person taking a decision as configured in the approval work flow.
|
NOTE: Script SCN_GetOrderValueStatus cannot be modified directly. If further customizations are required on this script, new custom scripts must be created by copying this script’s content and then changes can be done on the new script. Change the function’s name and use the same custom script name in the process step. process that references this script is SCN_Update_1IM_ticket_status_to_ ServiceNow. The internal process step where the script name should be modified is Script to process the OrderValue property of One Identity Manager. |