As a DataEngine Admin, you have the ability to extend the functionality of the MARINI DataEngine through custom JavaScript (JS). This allows for the creation of specific functions tailored to your use case. Whether you want to enhance interactions or add dynamic content, Custom JavaScript provides you with this flexibility.
Step-by-Step Guide
- Access the Admin Panel: Log into the DataEngine as an Admin and navigate to the Admin area.
- Locate the Custom JavaScript Section: Go to “System Settings” and select the “Custom JavaScript” section. Here, you can add custom JavaScript code for your system.
- Add JavaScript Code: Enter the JavaScript code that implements your desired functions. This could include customizing user interactions, editing data, or integrating third-party services. You can also use standard JS functions, such as event listeners, to dynamically respond to user inputs.
- Save Changes: After entering the JS code, save your changes. The new functionalities will be activated immediately across the system.
Tips & Best Practices
- Collaborative Work: Document your JavaScript code carefully, especially for complex functions. This helps other admins or developers understand the changes made.
- Debugging and Testing: Thoroughly test your code to ensure it does not cause unexpected errors, especially with extensive or complex customizations.
- Code Organization: Avoid unnecessarily long or inefficient code blocks. Break the code into well-structured functions to keep it maintainable.
- Consider Performance: JavaScript can impact the load times and performance of the DataEngine. Ensure your code is efficient to avoid unnecessary delays.
Advanced Use Cases
- Custom Validation: You can implement custom JavaScript validations to ensure that the entered data meets specific rules before being stored in the system.
- Automations: Use JavaScript to automate processes, such as updating data without requiring manual input from the user. This can be done by using APIs or webhooks to integrate external systems.
- Dynamic UI Adjustments: With JS, you can dynamically adjust the user interface, such as showing or hiding fields based on user actions.
Error Prevention and Security Considerations
- Input Validation: Validate user inputs not only on the client side with JavaScript, but also supplement it with server-side validation to prevent security risks like Cross-Site Scripting (XSS).
- Use Debugging Tools: Leverage browser consoles or JavaScript debuggers to identify and fix errors or warnings in your code early.
- Optimize Performance: Use asynchronous JavaScript (e.g.,
async
ordefer
attributes) to improve the loading speed of your page.
By leveraging custom JavaScript, you can significantly enhance both the user experience and the functionality of the MARINI DataEngine, tailoring it to meet your specific requirements and creating a customized solution.
Example: Page Reload after Inline Edit
Through Custom JS, you can trigger a page reload after an inline edit in the MARINI DataEngine. This can be useful when workflows are triggered after a record is saved, and values in the view (Detail View) should be recalculated and displayed immediately.
Use the following JS code
$(document).on('inlineEditSaveEvent', function (e, module, field) {
if (module === 'module_name' && field === 'module_field') {
location.reload();
}
});
The two variables module
and field
must be defined accordingly.
Important: Make sure that the “Inline Edit” function is activated for the defined field. You can check this in the Studio in the admin area.