Home Analyst Portal
Options

V7 - Custom Task - Analyst comment log

Valerie_SirouxValerie_Siroux Customer IT Monkey ✭
Hi 
We just upgrade to V7 and noticed our custom tasks which will update the action log stopped working.
I used this code before - in V5:
/*var newActionLog = {
EnteredBy: session.user.Name,
Title: localization.Analyst + " " + localization.Comment,
IsPrivate: this.isPrivate,
EnteredDate: new Date().toISOString(),
LastModified: new Date().toISOString(),
Description: this.actionLogComment,
DescriptionDisplay: this.actionLogComment,
Image: (this.isPrivate) ? app.config.iconPath + app.config.icons["privateComment"] : app.config.iconPath + app.config.icons["comment"],
ActionType: "AnalystComment"
}
if (!viewModel.ActionLog) {
viewModel.ActionLog = [];
}
actionLogModel.push(newActionLog); */

But after upgrade to v7 we get error: actionLogModel is undefined.

I managed to get it working for Resolved in this way : 
viewModel.AppliesToTroubleTicket = [{
"ActionType": {
 "Id": "5ca2cfee-6740-1576-540B-ce17222840b8",
 "Name": "Record Resolved"
},
"Description": this.get("comment"),
"EnteredBy": session.user.Name,
"EnteredDate": new Date().toISOString().split(".")[0],
"LastModified": new Date().toISOString().split(".")[0],
"Title": "Record Resolved",
"Image": "/Content/Images/Icons/ActionLogIcons/recordresolved.png",
"BillableTime": {
 "BasedId": null,
 "DisplayName": null
},
"LastUpdatedDisplay": null
}];
            },

But now - analysts need to click on OK before the action log appears.

Worse is that I am unable to convert this for a normal analyst comment - can't find actiontype for this?

Has anyone had the same issue and a solution for this?

Thanks

Answers

  • Options
    Valerie_SirouxValerie_Siroux Customer IT Monkey ✭
    Nevermind - Found it!
  • Options
    Olena_PrychynaOlena_Prychyna Customer IT Monkey ✭

    Having the same issue.

    Do you mind sharing the actiontype id for AnalystComment?

    Thanks

  • Options
    Valerie_SirouxValerie_Siroux Customer IT Monkey ✭
    Sorry - I only managed to fix this for one task, like this:
         var newActionLog = {
          Description: this.get("actionLogComment"),
          DescriptionDisplay: this.get("actionLogComment"),
          EnteredBy: session.user.Name,
          EnteredDate: new Date().toISOString().split(".")[0],
          LastModified: new Date().toISOString().split(".")[0],
          Title:  localization.Analyst + " " + localization.Comment,
          IsPrivate: this.isPrivate,
          Image: (this.isPrivate) ? app.config.iconPath + app.config.icons["privateComment"] : app.config.iconPath + app.config.icons["comment"],
          ActionType: "AnalystComment"     
         }
          console.log(this.isPrivate);
            if (!viewModel.ActionLog) {
           viewModel.ActionLog = [];
         }
         
         var actionLogType = app.controls.getWorkItemLogType(viewModel);
         if (actionLogType) {
          viewModel[actionLogType].push(newActionLog);
         }


    But don't manage to get this working for other tasks using appliestoworkitem.
    I really need the Id for those ones, but can't find it anywhere.

    finalsr.AppliesToWorkItem = [{
    Description: "Budget has been requested",
    DescriptionDisplay: "Budget has been requested",
    EnteredBy: session.user.Name,
    EnteredDate: new Date().toISOString().split(".")[0],
    LastModified: new Date().toISOString().split(".")[0],
    Title:  localization.Analyst + " " + localization.Comment,
    IsPrivate: false,
    Image: app.config.iconPath + app.config.icons["comment"],
    ActionType: "AnalystComment"
    }];
  • Options
    Olena_PrychynaOlena_Prychyna Customer IT Monkey ✭

    Works for us for Incident:

    incident.AppliesToTroubleTicket.push({
     "ActionType": "AnalystComment",  
     "EnteredBy": session.user.Name,

      "Title": "Analyst Comment",
      "IsPrivate": true,
       "EnteredDate": new Date().toISOString().split(".")[0],
       "LastModified": new Date().toISOString().split(".")[0],
       "Description": "private",
     "Image": "/Content/Images/Icons/ActionLogIcons/recordopened/privatecomment.png"
       });

  • Options
    Peter_FarrellPeter_Farrell Customer IT Monkey ✭
    We just updated our test system to 7.2 and ran into this problem.  I tried replacing with Olena's code, but it's not working either.  

    Here's an example of a task we have that marks the incident "Pending Affected User Reply" and should also add a comment to the action log.  The status change works, but nothing shows up in the action log.  Thanks in advance!
    <pre class="CodeBlock"><code>app.custom.formTasks.add('Incident', "Pending Affected User Reply", function (formObj, viewModel) {
        $.when(kendo.ui.ExtYesNoDialog.show({
            title: "Change Status",
            message: "Change the status to Pending Affected User Reply?"
        })
        ).done(function (response) {
            if (response.button === "yes") {
                //set new status
                viewModel.Status.set("Name", "Pending Affected User Reply");
                viewModel.Status.set("Id", "681a0b35-1d75-5550-f90c-732e2d785d5f");
    
    			var newActionLog = {
                        EnteredBy: session.user.Name,
                        Title: localization.Analyst + " " + localization.Comment,
                        IsPrivate: false,
                        EnteredDate: new Date().toISOString().split(".")[0],
                        LastModified: new Date().toISOString().split(".")[0],
                        Description: "The Status has been changed to Pending Affected User Reply",
                        Image: app.config.iconPath + app.config.icons["comment"],
                        ActionType: "AnalystComment"
    			}
    			actionLogModel.push(newActionLog);			
            }
        });
        return;
    });

  • Options
    Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
    The issue with both of these is that "actionLogModel.push()" has never really been a supported method, and stopped working somewhere around v6 or v7. There are other ways to add an action log comment. Attached is a bit of older code that shows an example of "Cancelling an Incident" and adding a message to the Action Log in the process. The snippets needed to rewrite these components should be in there-- let me know if you have any questions!
  • Options
    Peter_FarrellPeter_Farrell Customer IT Monkey ✭
    Thanks, Nick--I'm happy to see a familiar face!  Your code definitely helped--the cancel incident is fully working on 7.2.  Reverse engineering it to do other tasks, I'm able to change the status to what I'd like it to be, and I'm tweaking what it's posting to the action log. 

    Here's my updated action log code--it's working, but the icon is still showing the "Resolved" green check box, even though I changed it to comment.png.  I tried changing the ActionType to:
    "ActionType": "AnalystComment",
    like Olena mentioned above, but when I do that, the action log entry doesn't show up at all. I thought maybe I need to change the ActionType Name to "Analyst Comment", but then I don't know what to put for ActionType Id.  Any thoughts? 

    I appreciate your help!

    &nbsp;// Action log comment/icon indicating resolution<br>&nbsp;incident.AppliesToWorkItem = [{<br>&nbsp;&nbsp;"ActionType": {<br>&nbsp;&nbsp;&nbsp; "Id": "5ca2cfee-6740-1576-540B-ce17222840b8",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Name": "Record Resolved"<br>&nbsp;&nbsp;&nbsp;},<br>&nbsp;&nbsp;"Description": "The status has been changed to Pending Affected User Reply",<br>&nbsp;&nbsp;"EnteredBy": displayname,<br>&nbsp;&nbsp;"EnteredDate": new Date().toISOString().split(".")[0],<br>&nbsp;&nbsp;"LastModified": new Date().toISOString().split(".")[0],<br>&nbsp;&nbsp;"Title": "Analyst Comment",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Image": "/Content/Images/Icons/ActionLogIcons/comment.png",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "BillableTime": {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "BasedId": null,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "DisplayName": null<br>&nbsp;&nbsp;&nbsp;},<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "LastUpdatedDisplay": null&nbsp;&nbsp;<br>&nbsp;&nbsp;}];

  • Options
    Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
    Try replacing this:

    "ActionType": {<br>&nbsp;&nbsp;&nbsp; "Id": "5ca2cfee-6740-1576-540B-ce17222840b8",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Name": "Record Resolved"<br>&nbsp;&nbsp;&nbsp;<span>},</span>


    With this:

    ActionType: "AnalystComment",
  • Options
    Peter_FarrellPeter_Farrell Customer IT Monkey ✭
    edited January 2017
    Thanks, Nick! I tried that and it's not working. I'm so close--I think I have the entire thing working other than the "Resolved" icon showing up. Here's how I've done it. When I use "ActionType":"AnalystComment", the status changes, but then nothing gets placed in the action log. Any ideas? This is the last piece that's keeping us from moving forward with production upgrade to 7.2. Thanks!

    // Pending Affected User Reply -- Change the status and create an action log entry indicating the status change.
    function PAU_Incident (finalir) {
    var incident = finalir;
    incident.Status.Id = "681a0b35-1d75-5550-f90c-732e2d785d5f"; // Pending Affected User Reply
    var date = new Date()
    var addminute = 60*1000
    date.setTime(date.getTime() + addminute);
    var uid = session.user.Id;
    var displayname = session.user.Name;
    // Action log comment/icon
    incident.AppliesToWorkItem = [{
    /*"ActionType": {
     //"Id": "5ca2cfee-6740-1576-540B-ce17222840b8",
              "Name": "Record Resolved"
    },*/
    "ActionType": "AnalystComment",
    "Description": "The Status has been changed to Pending Affected User Reply",
    "EnteredBy": displayname,
    "EnteredDate": new Date().toISOString().split(".")[0],
    "LastModified": new Date().toISOString().split(".")[0],
    "Title": "Analyst Comment",
            "Image": "/Content/Images/Icons/ActionLogIcons/comment.png",
    }];
    }


  • Options
    Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
     Can you paste the entire customization? Tough to tell what is going on otherwise.

    Another thing that stands out is that "AppliesToWorkItem" is an array, so elements should be pushed to it. The way its written above, the entire Action Log would be replaced with the single entry and it might not be liking that.

    Something like this might be better (snippet from elsewhere, so it might not all be relevant here):

    // Add the comment to the action log 
    function Add_Comment(vm, desc){
            vm.AppliesToWorkItem.push({
                    EnteredBy: session.user.Name,
                    Title: localization.Analyst + " " + localization.Comment,
                    IsPrivate: true,
                    EnteredDate: new Date().toISOString(),
                    LastModified: new Date().toISOString(),
                    Description: desc,
                    DescriptionDisplay: desc,
                    Image: (true) ? app.config.iconPath + app.config.icons["privateComment"] : app.config.iconPath + app.config.icons["comment"],
                    ActionType: "AnalystComment"
            });
    }

Sign In or Register to comment.