Home Community Uploads
image

Cireson Partners, Customers and Community members share your customizations and examples here to help benefit the community as a whole to earn Kudos and badges.

DISCLAIMER

All files and projects located here are provided and come "as-is" and without any warranty or support. Use at your own risk. Your use of Community Uploads is subject to our Terms of Use.

Cireson does not and will not support or maintain these enhancements, extensions, and scripts.

For Team Cireson uploads click here.

Add Activity Task

Marc-Andre_LafleurMarc-Andre_Lafleur Customer Adept IT Monkey ✭✭
Add any type of activities to any type of work items.

Features
This task is based on Cireson's "Portal add MA to SR Task" with new features:
    - Add Manual, Review, Sequential or Parallel activity
    - Compatible with Service Requests, Incidents, Change Requests and Release Record
    - Activity Templates
        - Different templates for each activity types
        - Copy parent title & description template

No duplicate code for the different work item or activity types. I've reused the same code and functions so that it can stays as short and easy to modify as possible.

It is still possible to add the activity within the parallel activity.




Installation:
Copy the AddActivity.js file to your CiresonPortal\CustomSpace folder.
Copy the AddActivity.html file to your CiresonPortal\CustomSpace folder.
Copy the custom.js contents into your CiresonPortal\CustomSpace\custom.js file.

Setting up templates:
The templates are defined in the AddActivity.js file at Line 81. I've removed my templates from the files but I've kept some examples, including the "Copy parent title & description".
To add a template, copy one of the example template and change the values.
    Type: Add the Activity Prefix ("MA","RA","PA","SA") for which you want this template to appear for.
    TemplateName: The name of the template that will appear in the template dropdown menu.
    TemplateTitle: The title used by the template; what will show as the predefined title once the user select it.
    TemplateDescription: The predefined description. You may need to use escape characters. For example, use \n for line returns.

Features to add:
I would love to be able to add the activity implementer for Manual Activity directly from the window (instead of having to add the activity and the implementer in two steps). Also, support for multi-level activities would be great.
If someone from the community knows how we could do this, it would be a great addition!


Please test in your test environment first!

Download the attached .zip file below
«1

Comments

  • Joe_BurrowsJoe_Burrows Cireson Devops Super IT Monkey ✭✭✭✭✭
    Awesome, Thanks @Marc-Andre_Lafleur!
  • Robert_OsterbergRobert_Osterberg Customer Advanced IT Monkey ✭✭✭
    is this a feature request to Cireson? This has to be added to the native task list and be supported in the Portal
  • Kevin_StaceyKevin_Stacey Customer IT Monkey ✭
    Very nice, thanks @Marc-Andre_Lafleur ! Seems to work no problem for Incidents, whether I'm creating a new IR or modifying one I have the 'Add Activity' task. However, for Service Requests it seems to only add the task to an SR that already has one or more activities; I don't have the ability to add activities when creating an SR which is not a show-stopper, but I'm not able to add one after :(.
  • Marc-Andre_LafleurMarc-Andre_Lafleur Customer Adept IT Monkey ✭✭
    @Kevin_Stacey that would be because of the section at the top of the script that shows the task only for "In Progress" or "Active" work items. A Service Request without any activities would be in the "Submitted" status.

    If you replace the section at line 17 to 22 for the following, the task would now also appear and work for "Submitted" service requests:
    app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) {
    	formObj.boundReady(function(){
    		if(pageForm.viewModel.Status.Id != "59393f48-d85f-fa6d-2ebe-dcff395d7ed1" && pageForm.viewModel.Status.Id != "72b55e17-1c7d-b34c-53ae-f61f8732e425"){$( ".taskmenu li:contains('Add Activity')" ).hide();}
    		if(!session.user.Analyst) {$( ".taskmenu li:contains('Add Activity')" ).hide();}
    	});
    });

  • Alan_FosterAlan_Foster Customer Adept IT Monkey ✭✭
    edited June 2018
    @Marc-Andre_Lafleur , @Kevin_Stacey
    I have implemented this with the code above swapped.  When I am creating a new SR, I do not have the Add Activity.  After saving the SR and opening it again I do have the Add Activity.  In my environment, It looks like to me that when a SR is created it is in a status of "NEW" and not "submitted".

    Did you get this to work when creating a new SR?  
  • Marc-Andre_LafleurMarc-Andre_Lafleur Customer Adept IT Monkey ✭✭
    @Alan_Foster
    You can try the code below instead, it will show the task for all status except for Failed and Cancelled.
    app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) {
    	formObj.boundReady(function(){
    		// Hide the task for Cancelled or Failed Service Request
    		if(pageForm.viewModel.Status.Id === "674e87e4-a58e-eab0-9a05-b48881de784c" || pageForm.viewModel.Status.Id === "21dbfcb4-05f3-fcc0-a58e-a9c48cde3b0e"){$( ".taskmenu li:contains('Add Activity')" ).hide();}
    		if(!session.user.Analyst) {$( ".taskmenu li:contains('Add Activity')" ).hide();}
    	});
    });
    Using the task on a new SR will commit (save) the ticket. I didn't have enough time to fully test this but it should work.
  • Alan_FosterAlan_Foster Customer Adept IT Monkey ✭✭
    edited June 2018
    @Marc-Andre_Lafleur
    Thank you, here are my results.  If I just try to add the activity when creating I get this message:

    If I click Cancel it moves to the shaded screen that says "adding Activity" and gets stuck.
    If I click Leave it adds the activity and looks normal.
    If I click apply before attempting to add the activity it does not display the above message and adds the activity normally.  
    Is there a way to force it to "apply" when you select the Add Activity so that I don't get the above message?
  • Rod_MartenRod_Marten Customer IT Monkey ✭
    Marc:  First, thanks for the great work.  This is amazing and saved me a ton of time and headache.

    I have a need to have a templated activity that is added to the end of each activity sequence.  Unfortunately the default behavior doesn't let you add an activity before the first activity.  To address this, I added a dummy activity entry. The entry only shows up if the activity isn't in progress as that will cause workflow orphans.  Bold is my new code.

    // Create Activity Dropdown values that start with the Activity In Progress
     var activities = [];
     if(startpos == 0) {
      activities.push({
       "SequenceId": -1,
       "Title": "Beginning"
      });
     }

    A second issue is that it will cause an error if an activity is added before the parent work item is saved.  This is likely caused by my need to display in multiple statuses but if you have this problem you can add a test for last mod date which indicates it has been committed at least once.
    if(!(pageForm.viewModel.Status.Id.match("6188d6de-d719-5b6a-d700-a2a34316bcae"|"a52fbc7d-0ee3-c630-f820-37eae24d6e9b"))|(pageForm.viewModel.LastModifiedBy == null)){$( ".taskmenu li:contains('Add Activity')" ).hide();}
      if(!session.user.Analyst) {$( ".taskmenu li:contains('Add Activity')" ).hide();}

    Both of these are probably edge cases so not needed for everyone.

    Again, thanks for the great work.


  • Rod_MartenRod_Marten Customer IT Monkey ✭
    @Alan_Foster, see my second issue above.  That's probably your issue
  • Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
    Anyone had any joy adding runbook activities to this?
  • Joakim_NormannJoakim_Normann Customer Adept IT Monkey ✭✭
    We just upgraded the cireson portal to the latest version 9.0.3. After the upgrade we are able to create a parallel activity, but we can't add any activities to this parallel activity. Everything looks fine when we choose a manual activity and select it to be added to the PA. No error messages are received, but the activity doesn't appear under the PA.  Has anyone else encountered this issue? Are there any modifications needed in the AddActivity.js file for this to work like before the upgrade?
  • Marc-Andre_LafleurMarc-Andre_Lafleur Customer Adept IT Monkey ✭✭
    @Joakim_Normann I do have the same issue. I am not sure what is causing this yet, I've been able to add an activity within a PA using the API in powershell so it's still possible. I'll update the code here once I have a fix.
  • Joakim_NormannJoakim_Normann Customer Adept IT Monkey ✭✭
    @Marc-Andre_Lafleur Thanks for the quick feedback. I'm glad that we are not the only ones that has this issue. I appreciate your help with this.
  • Marc-Andre_LafleurMarc-Andre_Lafleur Customer Adept IT Monkey ✭✭
    edited March 2019
    Here's an updated version for 9.0x+
    I replaced viewModel by a GetProjection and activities added into Parallel Activity and now saving properly. I also fixed some bugs with status, Sequence Id and ActualStartDate for activity added "In Progress".
    @Joakim_Normann
  • Wendy_CraigWendy_Craig Customer IT Monkey ✭
    Thanks @Marc-Andre_Lafleur! We're not on 9.0x yet. I just tried it in version 8.12.9.2016 and when I drop down the "Place Activity After" box, I get "no data found". Any ideas? I'm going to do my best to go through the code, but I'm a complete hack at javascript. I appreciate your help with creating (and revising) this feature!
  • Nick_FlintNick_Flint Customer Advanced IT Monkey ✭✭✭
    Thank you, @Marc-Andre_Lafleur! I've tried everything I can think of to get app.lib.mask.apply('Adding Activity...'); to fire after clicking ok. Right now, it takes a bit before the mask shows and then it's only displayed for a second or two.
  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭

    Thanks for this! I was wondering if it would be possible to add a field to assign an Activity Implementer during the creation dialog?

  • Tracie_MarshallTracie_Marshall Customer IT Monkey ✭

    We recently upgraded to 9.3.10.2016 and it seems like there is an issue with adding MA to PAs. When I look in the developer console the following error code is listed:

    Uncaught TypeError: Cannot read property 'Status' of undefined

      at addActivityWI (<anonymous>:261:62)

      at init.okClick (<anonymous>:162:5)

      at i (jquery.min.js:2)

      at init.handlers.<computed> (kendo.all.min.js:29)

      at init.trigger (kendo.all.min.js:25)

      at init._click (kendo.all.min.js:37)

      at HTMLButtonElement.i (jquery.min.js:2)

      at HTMLButtonElement.dispatch (jquery.min.js:2)

      at HTMLButtonElement.y.handle (jquery.min.js:2)

    Are there any changes that we can make to fix this issue?

  • Roman_NepomniashchiiRoman_Nepomniashchii Customer IT Monkey ✭

    When I add activity my workflow is stopping and next activity after add stuck in pending, how I can fix this?

  • Carol_LeeCarol_Lee Customer IT Monkey ✭

    We just accidentally upgraded ours to version 9.6.0 (9.4.2 was the Latest version when I downloaded it), and this version broke the ascending order of the newly added MAs within the PA of a CR.  Please help!

    --PA870711

    ----MA870712 existing MA

    ----MA870776 new MA2

    ----MA870781 new MA3

    ----MA870727 new MA1

  • Peter_MiklianPeter_Miklian Customer Advanced IT Monkey ✭✭✭

    @Carol_Lee what's wrong with your example? You cannot expect MAIDs to be sequence of numbers. IDs are incremented with each created work item so if you created MA870727, then set of any SR/CR/MA/PA/SA/RA/... getting next numbers in row and then created new MA it could get ID MA870776 instead of MA870728.

    Activities in parallel activity (PA) are executed in parallel so their IDs/order doesn't matter.

    Tested in 9.6.0 in lab environment and Add Activity Tasks works without problems.

  • Carol_LeeCarol_Lee Customer IT Monkey ✭

    @Peter_Miklian so, the order that the new MAs are located does not matter? As long as the sequence numbers are in order then it is fine?

  • Tony_CollettTony_Collett Cireson Support Super IT Monkey ✭✭✭✭✭

    Yes Carol, that is correct. As long as sequence numbers are in order for the ticket, it doesn't matter what the MA ID numbers are (sequence IDs are generated and changed automatically and can be found in the history of a work item)

  • Peter_MiklianPeter_Miklian Customer Advanced IT Monkey ✭✭✭

    Yes, it's SequenceId what defines order of activities in parent Work Item (SR/CR/SA), not their Name, Displayname or ID and in PA (Parallel Activity) all run in parallel.

    SequenceId = 0 for the firs activity. If you change order of activities in SCSM console by drag&drop, their SequenceId should change.

    You can see all properties of MA using PowerShell:

    27Get-SCSMObject -Class (Get-SCSMClass ^System.WorkItem.Activity.ManualActivity$) -Filter 'Name -eq "MA870727"' | select *
    
  • Carol_LeeCarol_Lee Customer IT Monkey ✭

    Noted with thanks @Tony_Collett @Peter_Miklian

  • Roman_NepomniashchiiRoman_Nepomniashchii Customer IT Monkey ✭

    Hi Team, say me please how I can add template. I have two template for Review Activity, but in this feature show only one template "Default Review Activity" how I can show all my template for RA.


  • Gerhard_GoossensGerhard_Goossens Customer Advanced IT Monkey ✭✭✭
    edited April 2020

    When the cahebuilder sync again then it should be there

  • Roman_NepomniashchiiRoman_Nepomniashchii Customer IT Monkey ✭

    strange, the cachebuilder worked, but the template is still one

  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭

    What about after a app pool recycle and restarting your browser?

Sign In or Register to comment.