Widget - pass data to another widget to be used in server script

SC17
Tera Contributor

Hi.

I have 2 widgets. One has a GlideRecord script. I want to pass the result of this script to be used in another GlideRecord script in a different widget. I dont want to broadcast or emit the result to be used in HTML, I need to use the result in the server side.

Any ideas?

 

Thank you.

14 REPLIES 14

SC17
Tera Contributor

This is my setup:

- Record Producer action is called via Flow Designer, thus creating an HR Case with pre-filled variables

- An HR Task is also created with the HR Case as parent

- Created a new tab in the HR Task form (Portal) and when I click I want to get the HR Case variables (this tab calls the Variable Summarizer and the Variable Summarizer does not have access to the HR Case variables, cause we are on the task form)

- If I hard code the sys_id in the Variable Summarizer, I get the variables, but I need to pass the current HR Task - parent HR Case sys_id and I dont have access in the Variable Summarizer cause the Variable Summarizer uses getParameter('sys_id') BUT again I want the HR Parent case

 

SC17
Tera Contributor

Thanks for the reply.I managed to pass the value through the parameter, however, it keeps on refreshing the page each time I click on something (because of the $location and the url I am passing) thus resetting the list to the first item. Is there a way to pass via parameter, but instead of refreshing the page, I onyl refresh a certain widget using?

Thanks for more of the information but I meant specifically the setup of the widgets, like if they are on the same page as well as the code like the client script of the widget and the server side script of the receiving widget. Do you have full control over the two widgets?

Knowing some of these things may open up some other possibilities such as embedding the second widget (if widgets are on the same page) which would give you the ability to push options to the second widget or if you embed client side you can push inputs to the second widget.

It's difficult to give you guidance without knowing the existing capabilities of the two widgets.

-O-
Kilo Patron
Kilo Patron

$location are in no way meant to do what you are trying to do.

I don't even know how you made it work at all.

I believe it is a far better solution to re-write/modify the widget.

Add functionality where - if so defined - the GlideRecord that the variable summarizer loads is re-loaded as the "parent" table.

Perhaps something like:

 

	var record = sn_std_tkt_api.TicketConfig.getTicketRecord(tableName, sysId);
	
	// This, of course, should be loaded from somewhere, not maintained in code
	var redirectTableDB = { 'sn_hr_core_task': 'parent', };

	if (record == null)
		return;

	// Reload record (only) if so defined in redirectTableDB
	if (typeof redirectTableDB[tableName] != 'undefined')
		record = record.getElement('parent').getRefRecord();

 

@-O-  He probably means using the .url() method from $location. For example:

$location.url('place new url here and parameters if applicable') which is used for doing such a thing according to the AngularJS documents.