Show CR Activity History in the Portal

seth_coussensseth_coussens Product Owner Ninja IT Monkey ✭✭✭✭
,------. ,------.  ,---.  ,------.      ,--.   ,--.,------. 
|  .--. '|  .---' /  O  \ |  .-.  \     |   `.'   ||  .---' 
|  '--'.'|  `--, |  .-.  ||  |  \  :    |  |'.'|  ||  `--,  
|  |\  \ |  `---.|  | |  ||  '--'  /    |  |   |  ||  `---. 
`--' '--'`------'`--' `--'`-------'     `--'   `--'`------' 

   
|-------------------------------------------|
| Show Activity History Tasks Install Guide |
|-------------------------------------------|
 
Append the contents of custom.js to the custom.js file found in C:\inetpub\CiresonPortal\CustomSpace
on ALL over your portal servers.

Append the contents of custom.css to the custom.css file found in C:\inetpub\CiresonPortal\CustomSpace
on ALL over your portal servers and change the colour to meet your needs.

Copy the template HTML file to C:\inetpub\CiresonPortal\CustomSpace on ALL of your portal servers.

Refresh your browser to see the task. 

Comments

  • PIERRE-LOUIS_DURRISPIERRE-LOUIS_DURRIS Customer Advanced IT Monkey ✭✭✭
    I have seen that we can extract the user which completed a manual activity in SCSM
    http://www.systemcentercentral.com/get-user-marked-manual-activity-completed-scsm/ 
    Is it possible to add it to the function ?
    Today, we only have the workflow user in the history (as in the console).
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited June 2016
  • Michael_BaldryMichael_Baldry Customer Adept IT Monkey ✭✭
    This works awesome in Chrome, but there's a small CSS bug in IE11:

    The "position: fixed" seems to fix the "Close" button to the bottom of the main window, rather than the pop-up window. Is there an easy way to fix this up without breaking Chrome?
  • R_DelawderR_Delawder Member Adept IT Monkey ✭✭
    I had the same issue as above with the close binding to the bottom. had to remove the (style="position: fixed") from the "Var Htmlend =" line of the custom.js to correct the close button as previously referenced. I adjusted and put on the SR form using the same function as defined in for CR. (just copied the custom task and changed ChnageRequest to ServiceRequest)
  • Brad_McKennaBrad_McKenna Customer Advanced IT Monkey ✭✭✭
    Has anyone identified how to retrieve/display activities that are nested? I have  adapted this for SR's as well, and we are limited as we use nesting of activities.
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    Hi Brad,

    This section of the code, loops through the Activity array of the CR / SR and compliles a list of Activites for the Drop down.
    //Create Activity Dropdown values
    for (i=0; i < length; ++i) {
    		activities.push({
    		"Id": pageForm.viewModel.Activity[i].BaseId,
    		"Title": pageForm.viewModel.Activity[i].Id + " - " + pageForm.viewModel.Activity[i].Title
    	});
    }

    You will need to do a iterative loop into the Activity array on each activity to find nested activities and add them to the list. Once in the list, the rest of the code will work as it will just pass the Title and Id to the function that grabs history and displays it in the window.

    Geoff
  • Brad_McKennaBrad_McKenna Customer Advanced IT Monkey ✭✭✭

    Thank you Geoff! When attempting to create on my own, I ran across this post:

    https://community.cireson.com/discussion/355/view-manual-activity-history-in-the-portal

    I'm posting it here in case anyone else is in the same boat as us. On very long workflows, it will make the form take a second or two longer to load. I'm sure someone better at JavaScript than me could fix that up. :smile: 

    Function to get all child activities, not just the top level ones:
    function GetActivitiesRecursively(activities) {
        var allActivities = [];
        var length = activities.length;
            
        for (var i = 0; i < length; i++) {
            var currentActivity = activities[i];
            allActivities.push({            
    "Id": currentActivity.BaseId,
    "Title": currentActivity.Id + " - " + currentActivity.Title
            });
            // If the current activity has any child activities, process those too
            if (currentActivity.Activity && currentActivity.Activity.length > 0) {
                 allActivities = allActivities.concat(GetActivitiesRecursively(currentActivity.Activity));
            }
        }
        return allActivities
    }

    Change to how we create the custom task:
    app.custom.formTasks.add('ChangeRequest', "Activity History", function (formObj, viewModel) {
        var activities = GetActivitiesRecursively(pageForm.viewModel.Activity);
    CRGetActivityHistory(activities);
    });

    This looks similar to what you had suggested, and provides the ability to find all activities. (Although with this suggestion the creation of the custom task was altered to accommodate calling the function)

  • Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
    Good Afternoon @Seth_Coussens and Cireson Community,

    I'm trying this awesome customization out with Change Requests and when I look at an RA where a reviewer has been added or removed, it lists the item as a number versus the actual object (user display name) as shown in the screenshot below.



    Is there anyway to force this script to show the actual user that's being removed or added to the review activity?
    Any assistance you can provide would be most helpful!

    Thanks,

    Jonathan Boles
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    Hi @Jonathan_Bowles,

    This is one of my extensions so I'll jump in.

    Its to do with the 'double hop' relationship between RA and User. An RA has a Reviewer (these get assigned just a number) and a Reviewer has a User. So the History of the RA is correct that a a Reviewer of ID 49 has been added.

    To get the Actual User, we'll need to dive one level deeper in the case that the relationship is ReviewActivityHasReviewer. You would have to call the GetProjectionByCriteria API call to get the Reviewer object with the Type Projection of System.ReviewerProjection and this will include the User Object.

    Is that enough to get you going?

    Geoff
  • Brad_McKennaBrad_McKenna Customer Advanced IT Monkey ✭✭✭

    One thing I did in our environment was add in an Or statement (||) to only show the task when the ticket has activities (using the code referenced in my post above).

    From:

    app.custom.formTasks.add('ChangeRequest', null, function (formObj, viewModel) {
        formObj.boundReady(function () {
            var vm = pageForm.viewModel;
            //If the user is not an analyst, hide the task
            if (!session.user.Analyst) {
                $(".taskmenu li:contains('Activity History')").hide()
            }
        });
        return;
    });

    To:

    app.custom.formTasks.add('ChangeRequest', null, function (formObj, viewModel) {
        formObj.boundReady(function () {
            var vm = pageForm.viewModel;
      var length = vm.Activity.length;
            //If the user is not an analyst, hide the task
            if ((!session.user.Analyst) || (!(vm.Activity.length > 0))) {
                $(".taskmenu li:contains('Activity History')").hide()
            }
        });
        return;
    });

  • Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭
    Is there an actual code for both CR and SR activities?

  • Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭
    I have some problem, on the activity listy I don't see activities inside Parrarel Activity. Is there possibility to wiew nested activities?
Sign In or Register to comment.