get the logged user company to show/ hide fields in catalog item

dioni95
Kilo Expert

Hi all,

I need to identify the requester company to hide/ show specific fields. I´ve been trying with a client script and script include, but when I load the form a javascript appears. ' TypeError: Cannot read property 'initialize' of undefined'

Client Script:

function onLoad() {
   //Type appropriate comment here, and begin script below
   
	var ga = GlideAjax('GetUserCompany');
	ga.addParam('sysparm_name','getComp');
	ga.getXML(fulfillParse);
	
	
	function fulfillParse(response) {
     var answer = response.responseXML.documentElement.getAttribute("answer");   
	
		g_form.setValue('company', answer);
	}}

 

Script includes:

var GetUserCompany = Class.create();
GetUserCompany.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getComp: function() {
return gs.getUser().getCompanyID(); //returns sys id of an company to client script as an answer
}
	
	
});

 

Any advice will be helpful.

Thanks in advance

 

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Oh, meant to say the problem you are having is you are missing the "new" keyword:

var ga = new GlideAjax('GetUserCompany');

View solution in original post

5 REPLIES 5

I know: sometimes it's the simplest of things.  I've banged my head on a wall a lot because of slight typos.  Especially case-sensitive things.