The following article is an English translation of an article I posted here.
In SAP Build Code, currently only projects created with SAP Build's lobby or low-code templates are supported. If you try clicking the Joule icon in a project created with the cds init command, you'll receive a "Not Available" message.
However, the logic generation and test code generation features of Build Code are quite useful, and I wanted to try using them with existing projects.
By adding the following configuration to package.json, Joule can be enabled for existing code as well. Note, however, that this method is only effective for CAP Node.js and does not support Java.
"lcap": true
cds init <project_name>
At this point, Joule is not yet enabled.
Add the following setting.
"lcap": true
The complete configuration will look like this:
Install the @Sap/low-code-event-handler module. The template-generated code will use this module as illustrated in the following example.
/**
* Code is auto-generated by Application Logic, DO NOT EDIT.
* @version(2.0)
*/
const LCAPApplicationService = require('@sap/low-code-event-handler');
const books_Logic = require('./code/books-logic');
class CatalogService extends LCAPApplicationService {
async init() {
this.after('CREATE', 'Books', async (results, request) => {
await books_Logic(results, request);
});
return super.init();
}
}
module.exports = {
CatalogService
};
Refresh your browser and open Joule. (If you do not refresh, it will remain in the original state)
After this, I added a data model with cds add tiny-sample, generated application logic via Joule, and deployed to Cloud Foundry to confirm that it functions correctly.
Joule cannot be used with existing .js files. If you try opening Joule for event handlers that are already present, the "Open Guide" screen appears instead of Joule, and support for this source is not available.
If you add logic from the Graphical Modeler, it will overwrite the existing source. Therefore, if there are existing sources, they need to be backed up.
By simply adding a configuration to package.json, Joule can be activated for existing CAP Node.js projects, making it a more useful tool for pro-code developers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |