How to add a dropdown/selectbox to service portal approval record

Bruler1230
Tera Expert

Hello,

I have a request to add a dropdown/selectbox to the service portal approval record page. use case would be when an approver is approving a request, they would also like to have a dropdown that they can pick an option. For example, the approver could select from the dropdown "Go do this work" or "put this in the backlog" and then select Approve. Any ideas on this? or other solutions?

Thanks.

11 REPLIES 11

Bruler1230
Tera Expert

I am following up on this post to see if there is anyone that might be able to help out. I have a dropdown on the service portal approval page (in the approval info widget, specifically). Whenever the approves clicks approve, i need to get the value selected in the dropwdown transferred to the fulfiller view. And potentially use this value to determine which path the workflow will take. I still cannot figure out how to get the value from the dropdown. Any help is appreciated. Thanks.

I came across this when I was trying to implement something similar. In my case it's to get a rejection reason from the approver for a particular catalog item.

I used Mike's example above but the bit which I needed to add was in the HTML. It worked if I used the following code:

<button type="button" name="reject" class="btn btn-default btn-question" ng-click="c.action('rejected', data.abc)">${Reject}</button>
<div ng-if="c.data.abcbd" ng-init="data.abc='-'">
    <div><br /></div>
	<label class="m-n">${Rejection Reason}</label>
	<select ng-model="data.abc" type="text" class="select2-container" style="width: 100%;">
		<option value="{{reason.value}}" ng-repeat="reason in data.abc_reasons">{{reason.name}}</option>            
	</select>                 
</div>        
<textarea ng-model="c.data.comment" style="color: grey; width: 100%; margin-top: .5em;" placeholder="Rejection Comments" class="form-control" rows="5"></textarea>

The main difference is that you need to use an ng-model in the select and use the ng-init or else you'll get

? undefined:undefined ?

as an option.

In the client controller I've updated it as described above by Mike.

c.action = function(state, abc_bd) {
if (c.data.abcbd && abc_bd == "-" && state == 'rejected') {
	spUtil.addErrorMessage('A Rejection reason must be chosen for abc.');
	return false;
}

in the server script I've a check on the catalog item and if it's the one which needs a rejection reason I set data.abcbd = true;

Also in the server script the value from the dropdown can be accessed as follows:

if (input && input.op && data.isMine) {
   gr.state = input.op;
   if (input.comment) {
      gr.comments = input.comment;
      gs.log("PH:Widget:Approval Info with Rejection Comments:dropdown = " + input.abc);	
   }
}

I hope that helps.