How to stop UI Page Redirection after Clicking 'OK'

Mrman
Tera Guru

Hi All,

I have a UI page for transferring a HRCase to IT Group and once I select the Assignment group and Click OK .

The issue I have is after clicking on OK , the page is getting redirected and not staying on the same form . Please let me know what changes need to be done for achieving this . Below is the UI Page Client Script part .

find_real_file.png

function yesnoCheck(val)
{
	try
	{
		gel('selected_decision').value = val;
		if(val == '1')
		{
			gel('worknotesection').style.display = 'block';
			gel('commentssection').style.display = 'block';
			
		}
		else
		{
			gel('worknotesection').style.display = 'none';
			gel('commentssection').style.display = 'none';
		}
	}
	catch(e)
	{
		alert(e);
	}
}

function valdiateGrpValue()
{
	var finalresult;
	var groupErrorBlock = $j('#groupError');
	var groupValue = gel("assignment_group").value;
	
	if(groupValue == '')
	{
		groupErrorBlock.html(getMessage('Please select a group'));
		finalresult = false;
	}
	else
	{
		groupErrorBlock.html('');
		finalresult = true;
	}
	
	return finalresult;
}

function valdiateDecisionValue()
{
	try
	{
		var finalresult = false;
		var decErrorBlock = $j('#decError');
		var decisions = document.getElementsByName("decision");
		var tlscore = '';
		for (var i = 0, len=decisions.length; i< len; i++)
		{
			if (decisions[i].checked )
			{
				tlscore = decisions[i].value; // if so, hold its value in tlscore
				finalresult = true;
				break; // and break out of for loop
			}
		}
		
		if(finalresult)
		{
			decErrorBlock.html('');
			if(tlscore == '1')
			{
				var notesErrorBlock = $j('#noteError');
				if(gel('worknotes').value == '' || gel('worknotes').value == ' ' || gel('worknotes').value == 'undefined')
				{
					notesErrorBlock.html(getMessage('Please fill Work Notes'));
					finalresult=false;
				}
				else
				{
					notesErrorBlock.html('');
				}
			}
		}
		else
		{
			decErrorBlock.html(getMessage('Please select decision'));
		}
		
		return finalresult;
	}
	catch(e)
	{
		jslog(e);
	}
}

function submitCancel()
{
	GlideDialogWindow.get().destroy();
	return false;
}

function submitOk() {
	var result = $("assignment_group").value != undefined;
	
	if(!valdiateGrpValue())
		{
		result=false;
	}
	
	if(!valdiateDecisionValue())
		{
		result=false;
	}
	
	if (result)
		{
		$('cancel_button').addClassName('disabled');
		$('ok_button').addClassName('disabled');
	}
	
	return result;
}
15 REPLIES 15

Bhagyashri Sort
Kilo Guru

Hi,

You can try this

action.setRedirectURL(current);

Refer below links also

https://community.servicenow.com/community?id=community_question&sys_id=c5de440ddbb71740fff8a345ca96...

 

https://community.servicenow.com/community?id=community_question&sys_id=7db6c4d71be3bb84d01143f6fe4b...

 

Please mark it correct and helpful, if my response helps you.

 

Thank You

Bhagyashri Sorte