diff --git a/app/launchpage.html b/app/launchpage.html new file mode 100644 index 0000000..b5c5f8d --- /dev/null +++ b/app/launchpage.html @@ -0,0 +1,46 @@ + + +
+ + + + + + + + + + diff --git a/srv/services.js b/srv/services.js new file mode 100644 index 0000000..260ca82 --- /dev/null +++ b/srv/services.js @@ -0,0 +1,23 @@ +const cds = require('@sap/cds') + +class ProcessorService extends cds.ApplicationService { + /** Registering custom event handlers */ + init() { + this.before("UPDATE", "Incidents", (req) => this.onUpdate(req)); + this.before("CREATE", "Incidents", (req) => this.changeUrgencyDueToSubject(req.data)); + + return super.init(); + } + + changeUrgencyDueToSubject(data) { + let urgent = data.title?.match(/urgent/i) + if (urgent) data.urgency_code = 'H' + } + + /** Custom Validation */ + async onUpdate (req) { + let closed = await SELECT.one(1) .from (req.subject) .where `status.code = 'C'` + if (closed) req.reject `Can't modify a closed incident!` + } +} +module.exports = { ProcessorService }