How to retrieve value of a variable of catalog item in widget

Madala Chaitany
Giga Guru

Hi,

I am new to widgets creation. I have created a widget to display the dynamic link on the catalog form.

Could you please help me to retrieve the value of variable and pass it in the dynamic link.

HTML:

<div>
<!-- your widget template -->
<a href = "/src?p={{c.populateRole()}}" target="_blank">Click Here</a>
</div>

Server script:

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.role = getRole();

function getRole(){
var persona = $scope.page.role;
var assGrps = new GlideRecord("table_name");
assGrps.addQuery('persona', persona);
assGrps.query();
if(assGrps.next()){
var secGrp = assGrps.security_group;
var role = new GlideRecord("sys_group_has_role");
role.addQuery("group", secGrp);
role.query();
if(role.next()){
return role.sys_id;
}
}
}
})();

Client Controller:

api.controller=function() {
  /* widget controller */
  var c = this;
	
	c.populateRole = function(){
		c.roleSysyId = c.date.role;
		return c.roleSysId;
	};
	
};

Thanks in advance.

6 REPLIES 6

Hello @Navya Yetukuri 

 

Below YouTube videos have demo for the same, this should be helpful.

 

https://www.youtube.com/watch?v=sr_gqqxllRM

https://www.youtube.com/watch?v=pj68yoh0arI 

https://www.youtube.com/watch?v=qMo-30KbtWw 

 

The Serviceportal.io website currently looks to be down, you can check this later.

https://serviceportal.io/communicating-between-the-client-script-and-the-server-script-of-a-widget/

 

 

 

Thank you,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

IMG_20221020_180045.jpg

 in portal catalogue item,if i select any company that data from client controller send to server script to glide table,can please send code for this