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
11-01-2025 12:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2025 09:24 PM
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
11-02-2025 01:22 AM
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
11-02-2025 02:48 AM
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
11-02-2025 07:49 AM
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
11-03-2025 01:41 AM
Hi @aswini bc
you miss the comma (,) at line number 11 after }.
So it will be },