It's all about the answers!

Ask a question

Is it possible to configure RTC to automatically create an approval based on an enumeration literal using the value of another attribute as the title?


Timothy Distel (7319) | asked Aug 26 '19, 1:39 p.m.
edited Aug 27 '19, 7:39 a.m.

 Hello,


I am using CLM Suite 6.0.6.

I have a customer request to configure RTC to create an approval when a primary attribute on a work item is set to a particular literal. Not only this, but also to configure the behavior so that the name of each approval created by RTC is the value of a secondary attribute on the work item. I haven't seen this use case discussed anywhere and since I am not proficient in extending, I was curious as to if this is even possible to configure as a precondition or participant. If it is possible, what level of difficulty would the extension be compared to the solution provided here:


Any information is greatly appreciated.

Accepted answer


permanent link
Ralph Schoon (58.7k23642) | answered Aug 27 '19, 1:32 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Aug 27 '19, 1:33 p.m.
Yes, that can be done. You need a server extension (participant/follow up action). It can likely be done using unsupported JavaScript in the Web UI as well. Davyd is talking about that.

In addition to the post you cite, https://rsjazz.wordpress.com/ contains posts how to get started with server extension development (workshop) and several examples how to access work item attribute values.
Timothy Distel selected this answer as the correct answer

2 other answers



permanent link
Davyd Norris (1.1k8) | answered Aug 27 '19, 8:19 p.m.
Too long to post as a comment...

If you have access to the server then Ralph's approach is by far the best, as it translates well to all clients, but it's tough when you're on a SaaS instance.

The following JavaScript snippet creates a new approval via the undocumented WorkItemProxy - use at your own risk and peril!!! If you don't know what you're doing then Bad Things(tm) can happen!

The two Utils functions are used to check whether the approval already exists, and to retrieve a list of internal user ids that need to be added to the approval - in my Utils function this is done based on their assigned role in the team associated with the Filed Against category.

/*******************************************************************************
 * CLM workitem customisation scripts
 * (c) Copyright Davyd Norris 2019. All Rights Reserved.
 *
 ******************************************************************************/

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("og.Utilities");

(function() {
  var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
  var Utils = og.Utilities;

  var createApproval = function(workItem, title, filedAgainst, role, type) {
    if (Utils.hasApprovalBeenCreated(title)) {
      return;
    }
   
    var dueDate = new Date();
    var newApproval = {
      cumulativeState : "com.ibm.team.workitem.approvalState.pending",
      approvalType : 'com.ibm.team.workitem.approvalType.' + type,
      dueDate : dueDate.setDate(dueDate.getDate() + 2),
      name : title,
      approvals : [],
      _isNew : true
    };

    Utils.getCategoryList('projects')
    .then(function(projects) {
      var teamArea = projects.find(function(item) {
        return item.id === filedAgainst;
      }).teamArea;
      return Utils.getTeamMembersWithRole(teamArea, role);
    })
    .then(function(members) {
      for (var i = 0; i < members.length; i++) {
        newApproval.approvals.push({
          approver : {
            itemId : members[i]
          },
          state : 'com.ibm.team.workitem.approvalState.pending',
          _isNew : true
        });
      }
     
      var newId = workItem.getProxy().getValue( {path :[ 'approvals' ],defaultValue:[]} ).length;
      workItem.getProxy().setValue({
        ignoreChange: false,
        notifyEvenIfUnchanged:false,
        path: ['approvals', newId],
        value: newApproval
      });

      workItem.getProxy().storeWorkItem({
        self : this,
        operationMsg : "Saving",
        applyDelta : true,
        onSuccess : function(param) {
          console.log("Approval Saved");
        }
      });
    });
  };

})();

This is how you would use the function somewhere in your attribute customisation script (this one creates a Review type of approval):

var projId = workItem.getValue(WorkItemAttributes.FILED_AGAINST);
createApproval(workItem, 'Project Director Assessment', projId, 'Project Director', 'review');

Comments
Steven Hovater commented Aug 28 '19, 5:15 a.m.

tis a thing of beauty.. 


Davyd Norris commented Aug 28 '19, 5:38 a.m.
lol thanks mate :-)

They may drop the name Rational from the products but the Rat Pack will always live on!!

Timothy Distel commented Aug 28 '19, 6:30 a.m.

This is fantastic Davyd. Thank you for sharing.


permanent link
Davyd Norris (1.1k8) | answered Aug 26 '19, 9:45 p.m.
I've done this exact thing in the web client, so I know it's possible, but Ralph may have some server side code he can share with you.


Comments
Timothy Distel commented Aug 27 '19, 6:18 a.m.

Thanks for the response Davyd, How exactly did you accomplish this in the web client?

Your answer


Register or to post your answer.