How to redirect to a page on a button click?

Reddy
Kilo Sage

Hello All,

I want to redirect to a page after the user clicks on submit button.

 

HTML:

<button type="button" class="btn btn-primary"  ng-click="updatePrice(catalogItemValue.sys_id,myInputModels)" >SUBMIT</button>

 

CLIENT:

function($scope, spUtil) {
var c = this;
$scope.$on("field.change", function(evt, parms) {
//c.data.reason = parms.newValue;
c.data.servicecenter = parms.newValue;
  c.server.update().then(function(response) {         
               spUtil.update($scope);
       })
});
    $scope.updatePrice = function(myInputModels, sysiD) {
        alert('Are you sure want to update the record');
			c.data.myInputModels = myInputModels;
        c.data.sysID = sysiD;
 console.log('c.data');
			c.server.update(c.data).then(function() {});
		spUtil.update($scope);
    }
	
}

 

SERVER:

(function() {
var grlogged = gs.getUser().getDepartmentID();
data.incidents = [];
var gr = new GlideRecord('alm_hardware');
gr.addEncodedQuery("^u_device_type=Cell Phone");
gr.addQuery('department', grlogged);
gr.query();
var grcount = gr.getRowCount();
while (gr.next()) {
var catalogItemValue = {};
catalogItemValue.assettag = gr.getDisplayValue('asset_tag');
catalogItemValue.department = gr.getDisplayValue('department');
catalogItemValue.assignedto = gr.getDisplayValue('assigned_to');
catalogItemValue.servicecenter = gr.getDisplayValue('u_service_center');
catalogItemValue.mobileno = gr.getDisplayValue('u_mobile');
catalogItemValue.sys_id = gr.getUniqueValue();
data.incidents.push(catalogItemValue);
}
	
	var gr1 = new GlideRecord('alm_hardware');
	if(gr1.get(input.myInputModels)){
	  gr1.setValue('u_service_center',  input.servicecenter);
		gr1.update();
	}}
)();
1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

Within the client script, you redirect using something like:

var redirect = 'url'
top.window.location = redirect;

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

Within the client script, you redirect using something like:

var redirect = 'url'
top.window.location = redirect;

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Mohith Devatte
Tera Sage
Tera Sage

Hello ,

You can store the URL in some variable and use top.window.loaction for this

Example:

var redirect = '?id=my_approvals'
top.window.location = redirect;

you can replace it with your URL and you need to write this inside $Scope.updatePrice() function in your widget client controller script

Please accept this solution if it solves your problem 

thanks