Hi i am calling script include from client but it was showing "type" error in my code please give me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @aswini bc ,
try this scritp ..
var SampleScriptInclude = Class.create();
SampleScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, { // 1. Use AbstractAjaxProcessor for GlideAjax calls
userValues: function() { // 2. Corrected function name convention (camelCase)
var jspParam = this.getParameter('sysparm_name'); // 3. Corrected method and standard parameter name (sysparm_name)
// 4. Input validation: Always validate and sanitize input
if (!jspParam) {
return "Error: Required parameter missing.";
}
var gr = new GlideRecord('sys_user');
// 5. Use addQuery or setLimit for better performance, assuming 'jsp' is a user ID or name being passed
// For example, if 'jspParam' is a sys_id, the query would look like this:
gr.addQuery('sys_id', jspParam);
gr.setLimit(1); // 6. Best Practice: Limit records for single lookups
gr.query();
if (gr.next()) {
// 7. Standard practice is to return a JSON string or an object when using AbstractAjaxProcessor
var userEmail = gr.email.toString() || '';
var firstName = gr.first_name.toString() || '';
var lastName = gr.last_name.toString() || '';
// Return a structured string or JSON object
return userEmail + " & " + firstName + " & " + lastName;
/* If you want to return JSON (better practice):
return JSON.stringify({
email: userEmail,
firstName: firstName,
lastName: lastName
});
*/
} else {
return "User not found.";
}
},
type: 'SampleScriptInclude'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This is a syntax error, in your code line number 11 add a comma after }.
It should be like },
Please mark the answer correct/helpful accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @aswini bc ,
Modify line 11 to
}, (add comma at the end).
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Why do so many people post the same fix and ask that their answer be marked as the Correct answer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @aswini bc
you miss the comma (,) at line number 11 after }.
So it will be },
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
