Home Analyst Portal

Adding reviewer with API

Raymond_DidonatoRaymond_Didonato Customer IT Monkey ✭
edited December 2018 in Analyst Portal
I've been trying to add a reviewer using the API and I'm unable to get the reviewer to show up newly created RA.  When I look at the modded pageForm.viewModel, it looks promising:



Here is the code that I'm using.  I have a form with a select where someone can choose the reviewers they want.  The names are populated in a div below the select.  I use the API to retrieve the BaseId of each user selected.  When I did this for adding an activity implementer in a MA, all I seemed to need was the BaseId, but I can't seem to figure out what is required for a reviewer.  Does someone know what the format should look like?

var reviewer = [];
$('#selectedReviewers').find('.reviewerListItem').each(function() {
     var user = $(this).text();
     $.ajax({
          async: false,
          url: '/api/V3/User/GetUserList?userFilter=' + user,
          type: 'GET',
          success: function(data) {
               $.each(data,function(i) {
                   reviewer.push({
                               "ClassTypeId": "2f28a9ae-0e94-c895-c087-b222b231dd46",
                               "User": {"ClassTypeId": "10a7f898-e672-ccf3-8881-360bfb6a8f9a", "BaseId": data[i].Id, "ClassTypeId":                                     "10a7f898-e672-ccf3-8881-360bfb6a8f9a", "ObjectStatus": {"Id": "acdcedb7-100c-8c91-d664-                                                    4629a218bd94"}},
                               "Decision": {"Id": "dae75d12-89ac-a8d8-4fe3-516c2a6a26f7"}
                   });
               });
          }
     });
});

Thanks for your help.

Best Answers

Answers

  • Raymond_DidonatoRaymond_Didonato Customer IT Monkey ✭
    I would've never guessed I needed all that, but sure enough, it works!  Thanks!
  • Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
    Is there a way of doing this when using the push method on a review activity? I've tried adding the above after a "Reviewer" option but can't get it to work. Here's my review activity section for reference

    finalsr.Activity.push({
    						"ClassTypeId": "bfd90aaa-80dd-0fbb-6eaf-65d92c1d8e36",
    						"SequenceId": 5,
    						"Title": "Test",
    						"Description": "Test",
    						"Id": "T-RA{0}",
    						"Stage": {"Id": "8f76a43c-2ad0-acc8-6d71-789f2bd12762"},
    						"ApprovalCondition": {"Id": "c9822c46-f186-ca46-e00a-fca5b9a6819b"},
    						"ApprovalPercentage": 100,
    						"LineManagerShouldReview": "True",
    						"Reviewer": {"Comments": null,	"Decision": {"Id": "dae75d12-89ac-a8d8-4fe3-516c2a6a26f7", "Text": "Not Yet Voted", "Name": "Not Yet Voted", "HasChildren": false, "Ordinal": 15, "EnumNodes": []}, "ClassTypeId": null, "BaseId": null, "TimeAdded": null, "DecisionDate": null, "MustVote": false, "Veto": false, "User": {"Id": affu.Id}, "VotedBy": {"Id": null, "Name": null}},
    					});
    I'm trying here to add the affected user of the request in as a reviewer in this instance (obtained from pageForm.viewModel.RequestedWorkItem and stored as variable affu)
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    @Alex_Marsh - Are you trying to add an RA and a Reviewer at the same time?
  • Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
    edited February 2019
    @Justin_Workman yes that's correct. I'd like to generate the review activity with the reviewer already in it.
    I had (perhaps incorrectly) assumed that I could put the reviewer properties in as part of the review activity parameters which would only mean I needed 1 commit instead of adding the review activity, then adding another round of functions to add the reviewers

  • Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
    edited February 2019
    @Alex_Marsh
    I think you're almost there. But Reviewer is an Array not an object, as you can have more than 1 per RA. So wrap your Reviewer object in [ ] and i think that will work. Sorry not had time to test.
    Boom! Thanks @Geoff_Ross works a treat!
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Boom indeed!
Sign In or Register to comment.