How to set AssignedToUser equal to the CreatedByUser automatically

We want to setup a quick create and auto-solve for incidents and servicerequests that reached us by phone and got a quick fix. In our template we only expect our helpdesk dispatcher to fill up the AffectedUser and Title for an incident or servicerequest. We then have a workflow that auto-solves a quick-workitem.
The creation using template and the auto-solve workflow is working fine. The only thing we want to do nicer is setting the AssignedToUser to the CreatedByUser. We didn't see a solution using workflows and we tried this with the Cireson Powershell Activity extension. But the powershell activity app works only for servicerequests and changes, not for incidents.
How can we achieve our goal and through what customisation? 

Answers

  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭
    Do you have SCORCH or SMA running?
    Or can always create a powershell script that runs from SCORCH or SMA or as a windows scheduled task. Script it to run once a day to run thru all the incidents matching the template ID to then perform the Assigned to user relationship
  • Jeff_LangJeff_Lang Customer Advanced IT Monkey ✭✭✭
    if logging the incident/service request via the portal, something like the below should work for incidents and be easily modified for service requests as well, needs to go in the custom.js
    app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
    $(document).ready(function () {
    if(window.location.href.indexOf("/Incident/New/") > -1){
    pageForm.viewModel.AssignedWorkItem = pageForm.viewModel.CreatedWorkItem;
    }
    });
    });



  • john_doylejohn_doyle Cireson Support Ninja IT Monkey ✭✭✭✭
    Hi @Frederik_Vandendries ;

    A different solution would be to create a new page in the Portal. Here's an example:
    Create a file in the CustomSpace\views folder called quick-incident.js and enter this code in that file:
    {
        "Id": "view-quickIncident",
        "layoutType": "semantic",
        "pageTitle": "Raise a quick incident",
        "view": {
            "cssClass": "container-fluid",
            "content": [
                {
                    "cssClass": "row",
                    "content": [
                        {
                            "cssClass": "col-sm-9",
                            "content": {
                                "cssClass": "row",
                                "content": [
                                    {
                                        "cssClass": "col-md-12",
                                        "type": "viewPanel",
                                        "ViewPanelId": "QuickIncident"
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    }

    Next create a file called QuickIncident.js in the CustomSpace\views\viewpanels folder.
    Paste this code into that file. Replace the guid 'a77bb0c9-e201-dd93-230c-799a66d9e8fa' with the guid of your incident template.
    {
        "Id": "QuickIncident",
        "TypeId": "html",
        "Definition": {
            "content": "<h1>Quick Incident</h1><hr/><p>Handle incoming calls.</p><div class='panel'><div class='row'><div class='col-md-4 col-xs-12'><div class='demo-section k-content'><h4><label for='affectedUser'>Affected user:</label></h4><input id='affectedUser'/><div class='demo-hint'><em>Start typing the name of a user</em></div></div></div></div><div class='row'><div class='col-md-8 col-xs-12'><h4><label for='title'>Title:</label></h4><input id='title' style='width:100%' /></div></div></div><div class='row'><div class='col-md-4 col-xs-12'><button id ='saveIncident' style='width: auto;margin-top: 15px;margin-bottom: 15px;'>Save</button></div></div><script> $(document).ready(function () {$('#affectedUser').kendoComboBox({minLength: 3,dataValueField: 'Id',dataTextField: 'Name',filter: 'contains',autoBind: true,suggest: true,dataSource: new kendo.data.DataSource({transport: {read: {url: '/api/V3/User/GetUserList',data: {userFilter: function () {return $('#affectedUser').data('kendoComboBox').text();},filterByAnalyst: false,maxNumberOfResults: 10}}},serverFiltering: true})}); }); var jsonRaw; $.getJSON('/api/V3/Projection/CreateProjectionByTemplate', {'id': 'a77bb0c9-e201-dd93-230c-799a66d9e8fa','createdById': session.user.Id }).done(function (data) {jsonRaw = data; }); $('#saveIncident').on('click', function () {if ((typeof jsonRaw == 'undefined') || ($('#title').val().length == 0) || ($('#affectedUser').data('kendoComboBox').value().length == 0)) return; app.lib.mask.apply(); var originalData = JSON.stringify(jsonRaw);jsonRaw.AssignedWorkItem = {'BaseId': session.user.Id};jsonRaw.Title = $('#title').val();jsonRaw.RequestedWorkItem = {'BaseId': $('#affectedUser').data('kendoComboBox').value()};var newData = JSON.stringify(jsonRaw);var formData = '{\\'formJson\\':{\\'original\\':' + originalData + ',\\'current\\':' + newData + '}}';$.ajax({url: '/api/V3/Projection/Commit',type: 'POST',contentType: 'application/json; charset=utf-8',dataType: 'json',data: formData,success: function (data2) {app.lib.gotoFormReturnUrl();}}); }) </script>"
        }
    }

    The final step is to create a new link under Navigation settings.


    Now you will have a new form which will enable you to create incidents where the assigned user is the created by user. You could easily extend the code so that the analyst can choose whether to create an incident or a service request. The only thing that would change in the code is the template id. You could put radio buttons on the form for Incidents or Service Requests and then call the CreateProjectionByTemplate API with the appropriate template Id.
  • john_doylejohn_doyle Cireson Support Ninja IT Monkey ✭✭✭✭
    Hi @Frederik_Vandendries ;

    I modified the QuickIncident.js code
    {
        "Id": "QuickIncident",
        "TypeId": "html",
        "Definition": {
            "content": "<h1>Quick Incident or Service Request</h1><hr/><p>Handle incoming calls.</p><div class='panel'><div class='row'><div class='col-md-2 col-xs-6'><div class='demo-section k-content'><input type='radio' name='template' value='a77bb0c9-e201-dd93-230c-799a66d9e8fa'> Incident<br></div></div><div class='col-md-2 col-xs-6'><div class='demo-section k-content'><input type='radio' name='template' value='03bc9162-041f-c987-8ce4-a5547cd9ca04'> Service Request<br></div></div></div><div class='row'><div class='col-md-4 col-xs-12'><div class='demo-section k-content'><h4><label for='affectedUser'>Affected user:</label></h4><input id='affectedUser'/></div></div></div><div class='row'><div class='col-md-8 col-xs-12'><h4><label for='title'>Title:</label></h4><input id='title' style='width:100%' /></div></div></div><div class='row'><div class='col-md-4 col-xs-12'><button id ='saveIncident' style='width: auto;margin-top: 15px;margin-bottom: 15px;'>Save</button></div></div><script> $(document).ready(function () {$('#affectedUser').kendoComboBox({minLength: 3,dataValueField: 'Id',dataTextField: 'Name',filter: 'contains',autoBind: true,suggest: true,dataSource: new kendo.data.DataSource({transport: {read: {url: '/api/V3/User/GetUserList',data: {userFilter: function () {return $('#affectedUser').data('kendoComboBox').text();},filterByAnalyst: false,maxNumberOfResults: 10}}},serverFiltering: true})}); }); var jsonRaw; $('input[name=template]').change(function(){var templateID = this.value;app.lib.mask.apply();$.getJSON('/api/V3/Projection/CreateProjectionByTemplate', {'id': templateID,'createdById': session.user.Id }).done(function (data) {jsonRaw = data; });app.lib.mask.remove();}); $('#saveIncident').on('click', function () {if ((typeof jsonRaw == 'undefined') || ($('#title').val().length == 0) || ($('#affectedUser').data('kendoComboBox').value().length == 0)) return; app.lib.mask.apply(); var originalData = JSON.stringify(jsonRaw);jsonRaw.AssignedWorkItem = {'BaseId': session.user.Id};jsonRaw.Title = $('#title').val();jsonRaw.RequestedWorkItem = {'BaseId': $('#affectedUser').data('kendoComboBox').value()};var newData = JSON.stringify(jsonRaw);var formData = '{\\'formJson\\':{\\'original\\':' + originalData + ',\\'current\\':' + newData + '}}';$.ajax({url: '/api/V3/Projection/Commit',type: 'POST',contentType: 'application/json; charset=utf-8',dataType: 'json',data: formData,success: function (data2) {app.lib.gotoFormReturnUrl();}}); }) </script>"
        }
    }

    Here's what it looks like in the portal.



  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭
    edited December 2017
    @john_doyle or @Jeff_Lang
    I have spent a good amount of time training my analysts to use the service catalog as it performs the proper data mapping that we then use for reporting. 
    Was attempting to use the powershell activity to set the assigned to user but it doesn't work on IR's. 
    Is it possible to have a trigger on specific SO's to make the relationship?

    And side note diffidently going to work on adding the quick create for my desk that takes first line phone calls.
  • john_doylejohn_doyle Cireson Support Ninja IT Monkey ✭✭✭✭
    Hi @Brian_Wiest ;

    With the ARO, you can add a direct link to a Request Offering, so you could still redirect them to a form like this through the service catalog.
  • john_doylejohn_doyle Cireson Support Ninja IT Monkey ✭✭✭✭
    @Brian_Wiest ;
    That said, I don't think the system would associate the resulting ticket with the RO, so it would have to be done by the form itself when creating the ticket.
Sign In or Register to comment.