Service Portal Add to Cart Behavior

jmiskey
Kilo Sage

We just enabled the "Add to Cart" button to one of our Service Catalog Items.  When we complete a request and click "Add to Cart", we notice that it just stays on the current Form (and disables all the fields).  Is there a way to have it go back to the main Service Portal menu after clicking "Add to Cart"?  Is that a configurable setting, or do we need to alter a widget?

Thanks

6 REPLIES 6

Sharvan
Giga Guru

Hi  Jmiskey,

 

You can modify your widget to do that.

 

In Client Script of your widget you can add the below code in addToCart() function:

 

function addToCart() {
postCatalogFormRequest().success(function(response) {
$rootScope.$broadcast("$sp.service_catalog.cart.add_item");
$rootScope.$broadcast("$sp.service_catalog.cart.update");
//spUtil.addInfoMessage("Added item to shopping cart");
//$scope.submitted = true;
// $scope.adding = false;
$scope.addtocartButtonMsg=$scope.m.addedtocartMsg;

 


$window.location.href="/sp?id=service_catalog_page&sys_id=ff0143a7db485f001eeada94ce961902";


});

 

you can modify the bold code with the page you want to redirect to.

 

Regards

Shravan

Thanks.  Please forgive me, I have not worked much with Widgets yet.  If I understand correctly, I should first clone my widget and edit that clone instead of the original.  

Then it looks like this client script you mention I can find in the "Client Controller" section of my widget, yes?

Lastly, how do I tell it to use my new cloned widget instead of the original one?

Thanks!