Home General Discussion
Options

"Affected User "not displayed when SR created through API

Manas_GautamManas_Gautam Customer IT Monkey ✭
edited March 2023 in General Discussion

Hi, we have a requirement to create IR/SR using API. We are planning to use the cireson APIs (https://support.cireson.com/Help#overview). We are trying to recreate what is done in this website (https://cireson.com/blog/integrate-external-systems-with-cireson-portal/) by using Postman application. We are using "Authorization/GetToken" API first, to fetch the token for authorization. Then we are using "Projection/CreateProjectionByTemplate" API and passing the templateId of "Default Service Request" to fetch the json template of the service request. After that we are using the "Projection/Commit" API to submit the service request by changing the JSON Values like Title etc. I get a response object which has values like "success" : true and also has a "BaseId" value. The problem now we are facing is that we are able to get the service requested created but in the affected users row we are not able to see any user's name. We have tried adding "AffectedUser" object in the formJson where we passed Name and id as object parameters but it did not work. Can you please guide us on what to change in the formJson so that we can view the AffectedUser in the portal.

Best Answer

  • Options
    Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭
    Answer ✓

    The object property is RequestedWorkItem, not AffectedUser.

    Setting Affected User at creation works fine for us, by setting RequestedWorkItem on the form to an object with ClassTypeId, BaseId, and DisplayName of the user, e.g.:

    template.RequestedWorkItem = [{
               ClassTypeId: '10a7f898-e672-ccf3-8881-360bfb6a8f9a', // Domain.User GUID
               BaseId: formData.contactId, // User Object GUID
               DisplayName: formData.contactName // User Object DisplayName
             }];
    

    This is POSTed to /api/V3/Projection/Commit

Answers

  • Options
    Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @Manas_Gautam we have the same issue with the cloud connector.

    We cannot define the affected user during creation. What we do is, we try to receive the workitem in a loop, and after the response contains the work item, we set the affected user via cloud connector. Especially for standard properties and relationships, the cloud connector is much easier and faster to use. Also with the Cloud Connector it is not required to pass credentials, as you might define a token inside the portal and it might be used for connecting - But as it is not possible to define a template id, especially for CRs (especially CRs as they cannot be completed without an Activity in it) and SRs it is not sufficient for any workitem with activities in it.

    tl;dr: Create the SR with the API, then try to receive the SR via the cloud connector, and as soon as this is successful, change the affected user.

  • Options
    Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭
    Answer ✓

    The object property is RequestedWorkItem, not AffectedUser.

    Setting Affected User at creation works fine for us, by setting RequestedWorkItem on the form to an object with ClassTypeId, BaseId, and DisplayName of the user, e.g.:

    template.RequestedWorkItem = [{
               ClassTypeId: '10a7f898-e672-ccf3-8881-360bfb6a8f9a', // Domain.User GUID
               BaseId: formData.contactId, // User Object GUID
               DisplayName: formData.contactName // User Object DisplayName
             }];
    

    This is POSTed to /api/V3/Projection/Commit

  • Options
    Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @Konstantin_Slavin-Bo works with the V3 API, but unfortunately not with the cloud connector :(

  • Options
    Manas_GautamManas_Gautam Customer IT Monkey ✭
    edited March 2023

    Hi @Simon_Zeinhofer,

    Thank you for your response. I tried a few Cloud connector APIs and was able to perform the GetWorkItem and CreateWorkItem operations, but I encountered some issues with other APIs, particularly those involving PUT and PATCH operations, as I was unable to update workitems or add comments to workitems. And how do you add the "Affected User" for a workitem via cloud connector APIs? Thank you for your help.

    Thanks,

    Manas

  • Options
    Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @Manas_Gautam which version of the portal are you running?

    With 11.8.2 the PUT and Patch are not working. The Affected User can be added like this:

    $affectedUser = @{ "RequestedWorkItem" = @{
            "BaseId" = "USERGUID"
        };
    }
    
    
    #Update the Work Item
    $rest = Invoke-RestMethod -Uri $YOURURL -Method "PUT" -Headers @{"Authorization"="$platformToken"} -Body $($affectedUser | convertto-json) -ContentType "application/json"
    

    This works as soon as the workitem can be returned.

  • Options
    Manas_GautamManas_Gautam Customer IT Monkey ✭
    edited March 2023

    Hi @Simon_Zeinhofer @Justin_Workman,

    I'm using portal version 11.8.2, and thanks for informing me that PUT and PATCH operations aren't working with this version; could you please tell me what the workaround is for getting the PUT and PATCH cloud connector APIs to work?

    Thanks,

    Manas

  • Options
    Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @Manas_Gautam Unfortunately there is no workaround for that. Just waiting for a new realease - I am also very unhappy about that and hope the the dev team will release a fix for that soon.

Sign In or Register to comment.