How to hide the order confirmation popup in service portal for single catalog item

Nag9
Tera Expert

Hello developers,

I have requirement to hide the order confirmation popup window in service portal for a single catalog item.

For that i cloned the existing widget and applied it new page, here in clone widget client script i added this line at funtion get one

$scope.data.sys_properties.twostep= false; 

Now, order confirmation is disabled, But it is creating REQXXX instead of Creating RITMXX.

If i remove the newly added line, its working fine

 

Here im attaching the clone widget code snippets and as well as output of after order confirmation before adding the code and after adding the code

 

 

Any leads shoud be appreciated

 

Thanks

Nag

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi,

Here is the updated code.

In your catalog item widget, add this else if condition.

else if (input.action == "order_cat_item") {
  var gr = new GlideRecord("sc_req_item");
  gr.addQuery('request',input.itemDetails.sys_id);
  gr.query();
  if(gr.next()) {
    data.ritm=gr.sys_id;
  }
}

 

Then go to your catalog item widget and in your client script, add this code in getOne().

 

$scope.server.get({
  action: 'order_cat_item',
  itemDetails: {
  sys_id: a.sys_id,
  name: $scope.data.sc_cat_item.name,
  sys_class_name: $scope.data.sc_cat_item.sys_class_name
}
}).then(function(r){
  $location.search('id=ticket&is_new_order=true&table=sc_req_item&sys_id=' + r.data.ritm);
});

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

10 REPLIES 10

Tried asif, but unfortunately we don't have rights to open inspect option to check that console log

Hello Nag,

In your catalog checkout widget, look for this function and make changes as given below

	if (localInput && localInput.action === 'checkout') {
		var request = cartJS.checkoutCart(true);
		var grItem = new GlideRecord("sc_req_item");
		grItem.addQuery('request',request.request_id);
		grItem.query();
		if(grItem.next()) {
			data.ritm = {sys_id: grItem.sys_id, number: grItem.number, table: 'sc_req_item'};
		}
		data.result = {sys_id: request.request_id, number: request.request_number, table: 'sc_request'};
		$sp.logStat('Checkout Request', 'sc_request', request.request_id);
		return;
	}

 

Then go to your catalog item widget and in your client script, make these changesin the following function.

 

spScUtil.orderNow($scope.data.sc_cat_item.sys_id, $scope.data.sc_cat_item.quantity, getVarData($scope.data.sc_cat_item._fields), $scope.data._generatedItemGUID, additionalParms).then(function(response) {
	var a = response.data.result;
	var ritm = response.data.ritm;
        $scope.$emit("$$uiNotification", a.$$uiNotification);
	$scope.$emit("$sp.sc_cat_item.submitted", a);
	if (c.options.auto_redirect == 'false') {
	        $scope.submitting = false;
		$scope.submitted = true;
		$rootScope.$broadcast("$sp.service_catalog.cart.submitted", true);
		spUtil.addInfoMessage($scope.m.requestSubmitted);
		return;
	} else if (!$scope._atf) {
		$location.search('id=ticket&is_new_order=true&table=sc_req_item&sys_id=' + ritm.sys_id);
        }
});

 

Mark the comment as a correct answer and helpful once worked.

Also in line 535, you see handleReidrect(

Need to update that line as well with the ritm sys_id

asifnoor
Kilo Patron

Hi,

Here is the updated code.

In your catalog item widget, add this else if condition.

else if (input.action == "order_cat_item") {
  var gr = new GlideRecord("sc_req_item");
  gr.addQuery('request',input.itemDetails.sys_id);
  gr.query();
  if(gr.next()) {
    data.ritm=gr.sys_id;
  }
}

 

Then go to your catalog item widget and in your client script, add this code in getOne().

 

$scope.server.get({
  action: 'order_cat_item',
  itemDetails: {
  sys_id: a.sys_id,
  name: $scope.data.sc_cat_item.name,
  sys_class_name: $scope.data.sc_cat_item.sys_class_name
}
}).then(function(r){
  $location.search('id=ticket&is_new_order=true&table=sc_req_item&sys_id=' + r.data.ritm);
});

Mark the comment as a correct answer and also helpful once worked.

Nag9
Tera Expert
Updated the code Thanks asif its working perfectly