I want to display my name when incident form is loading using script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2025 08:46 AM
this code is not working for me anyone please suggest if want any correction in code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2025 09:14 AM
Its
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2025 10:11 AM
You can use the below script:
function onLoad() {
//Type appropriate comment here, and begin script below
var name=new GlideAjax('showusername');
name.addParam('sysparm_name','getname');
name.addParam('sysparm_populate','testinguser');
name.getXMLAnswer(callback);
function callback(response){
var answer=response;
alert(answer);
}
}
Script include:
var showusername = Class.create();
showusername.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getname : function(){
var usernamevalue=this.getParameter('sysparm_populate');
var usertostring=usernamevalue.toString();
return usertostring;
},
type: 'showusername'
});
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2025 10:23 PM
Hello @POOJAP724406436, Please change your line number 3 in Client Script as follows and then it should work.
x.addParam('sysparm_name', 'getGreeting');
you used sysparam_name that has an 'a' extra.
P.S: your SI and CS look fine, but better to use getXMLAnswer over getXML as former one returns only 'answer' while getXML returns whole XML object.
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2025 11:53 PM
Hello @POOJAP724406436
There is a typo in the client script.
When calling a script include function from client script it should be "sysparm_name".
It should be:
x.addParam('sysparm_name','getGreeting');
Replaced "sysparam_name" with "sysparm_name".
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar