(function process(request, response) {
// Extract the sys_id from the request
var sysId = [Link].sys_id;
if (!sysId) {
[Link](400); // Bad Request
return [Link]({ error: "sys_id parameter is required" });
}
var incidentGR = new GlideRecord('incident');
if ([Link](sysId)) {
// Build the response
var result = {
sys_id: [Link]('sys_id'),
number: [Link]('number'),
short_description: [Link]('short_description'),
priority: [Link]('priority'),
state: [Link]('state'),
};
[Link](200); // OK
[Link](result);
} else {
[Link](404); // Not Found
[Link]({ error: "Incident not found for sys_id: " + sysId });
}
})(request, response);
/
*----------------------------------------------------------------------------------
---------*/
/* Alternative code */
/
*----------------------------------------------------------------------------------
---------*/
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
// implement resource here
var sys_id = [Link].sys_id;
var gr = new GlideRecord('incident');
[Link]('sys_id', sys_id);
[Link]();
if ([Link]()) {
var body = {};
[Link] = [Link];
body.short_description = gr.short_description;
[Link](body);
}
})(request, response);