Comments on: Reload a Form or Related list from a Client Script https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 19:43:31 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mila Morales https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9361 Thu, 21 Sep 2017 19:22:13 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9361 In reply to Adam Katulak.

There is no possible way to clear the related list by using a UI action on the current form. If you don’t like the related list to be displayed on the form you can remove these lists by configuring the related lists or by creating a button on the related list that will display the records that you need.

]]>
By: Adam Katulak https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9360 Wed, 07 Jun 2017 21:01:15 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9360 Is there anyway that an embedded list can be cleared via a client script or UI action? Basically I would like to hit a UI action on my form that clears all the writable fields, and also does the same behavior as clicking the red x (delete) next to each row in my embedded list.
Thanks!

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9359 Thu, 27 Apr 2017 18:20:31 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9359 In reply to Eric Pace.

If it’s a UI action running a client script (as this would need to be) then you need to use the ‘onclick’, and ‘client’ fields. You would also need to wrap the ‘try/catch’ block in a function which would need to be called from the ‘onclick’ field by its function name. You can look at other UI actions in the system that have the ‘Client’ field marked as true to see some examples of how this would be done.

]]>
By: Eric Pace https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9358 Thu, 27 Apr 2017 17:44:52 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9358 In reply to Eric Pace.

Cancel that. I used the name, not label. I read through the instructions too fast previously. Either way, it’s still not functioning properly for me.

]]>
By: Eric Pace https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9357 Thu, 27 Apr 2017 17:18:06 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9357 Hey Mark –

I’m attempting your embedded list script and not having any luck. Does it still require the onclick, client, and condition? I would assume not. I have given my relationship a label and replaced the “Affected CIs” with it, but it still refreshes the entire page, instead of just the embedded list. Ideas?

]]>
By: David https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9356 Fri, 18 Dec 2015 20:56:33 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9356 Hello,

Can you disable/remove status options from a list? Lets say I want to remove the close status from the incident list without using ACLs.

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9355 Thu, 10 Apr 2014 00:39:31 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9355 In reply to Steve.

There’s a lot more to your script than a simple list refresh. I’ve confirmed that the embedded list refresh works fine in a SN demo environment so I know that’s not the problem here. The only thing I can suggest is to break your script down into more basic sections so you can see where the conflict is. You should probably start with a basic action-invoked refresh and then work up from there.

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9354 Thu, 10 Apr 2014 00:34:43 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9354 In reply to Lindsey.

This question is more of a general ServiceNow configuration question so you should probably ask this on the ServiceNow community site.

]]>
By: Steve https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9353 Wed, 09 Apr 2014 23:39:46 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9353 Mark,

Thanks for all the tips you provide, it is very helpful.

I have a requirement where the Affected Group needs to be embedded to our Change Request form. When the user click on “Request for Approval” UI Action, it will check if there are Affected Groups. If none, it will open a slushbucket (which is also from your site: https://servicenowguru.com/system-ui/ui-actions-system-ui/creating-custom-slushbucket-popup-dialog/). I tried to do the code above on refreshing embedded related list, could not get it to work. How does the code for refreshing embedded related list work? Below is the UI Action code. Any help is greatly appreciated.

function requestApproval() {
	if (g_form.getValue('assigned_to') == '') {
		try {g_form.hideFieldMsg('assigned_to');} catch(e1) {}
		g_form.setMandatory('assigned_to', true);
		g_form.showFieldMsg('assigned_to','Assigned to is required when requesting approval','error');
		return false;  //Abort submission
	}
	var affectedGrp = new GlideRecord('task_group');
	affectedGrp.addQuery('task', g_form.getUniqueValue());
	affectedGrp.query();
	if (!affectedGrp.next()) {
		if (g_form.modified) {
			gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
			gsftSubmit(null, g_form.getFormElement(), 'request.approval'); //MUST call the 'Action name' set in this UI Action
		}
		var dialog = new GlideDialogWindow('affected_groups');
		dialog.setTitle('Affected Group');
		dialog.setPreference('sysparm_groupQuery', 'source=change_request');
		dialog.render();
		try {
			var elementLookup = $$('div.tabs2_list');
			var listName = "Groups affected";
			alert('elementLookup: ' + elementLookup);
			for (i = 0; i < elementLookup.length; i++) {
				if (elementLookup[i].innerHTML.indexOf(listName) != -1) {
					var listHTML = elementLookup[i].id.split('_');
					var listID = listHTML[0];
					alert('listID: ' + listID);
					nowRefresh(listID);
				}
			}
			
			function nowRefresh(id) {
				GlideList2.get(id).refresh('');
			}
		}
		catch (err) {}
		// gsftSubmit(null, g_form.getFormElement(), 'request.approval'); //MUST call the 'Action name' set in this UI Action
		return false;
	}
	
	//Call the UI Action and skip the 'onclick' function
	gsftSubmit(null, g_form.getFormElement(), 'request.approval'); //MUST call the 'Action name' set in this UI Action
	
}

if (typeof window == 'undefined')
	requestForApproval();

function requestForApproval(){
	current.approval='requested';
	current.state = -5;
	current.update();
	action.setRedirectURL(current);
}
]]>
By: Lindsey https://servicenowguru.com/client-scripts-scripting/reload-form-related-list-client-script/#comment-9352 Wed, 09 Apr 2014 21:26:19 +0000 https://servicenowguru.wpengine.com/?p=4565#comment-9352 In reply to Mark Stanger.

I have another question, which I know is basic: How do I pass multiple variables to an extended table?

I have “Cards” for time cards, and I have “Time” to record actual time (Extention of CARD). On the CARD, end users record the reporting period, HR hours recorded (to calculate against) and that is basicially it. The other fields are auto-filled.

Each Time entry has many more fields, but also need to include the name of the person on the CARD (in case the manager is filling it out) as well as the timeframe. Both of these are lookup fields, and exist on CARD. I have tried everything I can think of, and everything I can find, but I’m not having any luck.

Could you point me in the right direction? In general, I have not had good luck with passing variables anywhere in SN — I did some workflows a few weeks ago that I FINALLY got to work, but it took a lot of doing.

Thank you again for your feedback!

~Lindsey

]]>