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

Comments

  • Joe_BurrowsJoe_Burrows Cireson Devops Super IT Monkey ✭✭✭✭✭
    Awesome, Thanks @Marc-Andre_Lafleur!
  • Robert_OsterbergRobert_Osterberg Customer 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 26
    @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 26
    @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
Sign In or Register to comment.