Skip to content

Instantly share code, notes, and snippets.

probably working on an APEX Plugin

Stefan Dobre stefandobre

probably working on an APEX Plugin
View GitHub Profile
View apex-mle-example-3.js
const marked = requireModule('marked');
// library-specific options
headerIds: false
apex.env.P5_HTML = marked(apex.env.P5_MARKDOWN);
View apex-mle-example-1.js
// calling our custom requireModule function
const qrcode = requireModule('qrcode');
// library specific options
const code = qrcode(4, 'L');
// saving the base64 result into a page item of type Display Image
apex.env.P1_QR_CODE = code.createDataURL(4);
View apex-mle-require-module.js
// fetch the library from the table
const loadFromDatabase = (moduleName) => {
const result = apex.conn.execute(`
select source
  from javascript_modules
  where module_name = :name
`, {
name: moduleName
View apex-mle-get-libraries.sql
type module_t is table of varchar2(100) index by varchar2(100);
l_modules module_t := module_t();
l_module varchar2(100);
l_code clob;
/* store the name and location of each library that is to be imported */
l_modules('qrcode') := '';
l_modules('validator') := '';
l_modules('marked') := '';
View apex-mle-create-table.sql
create table javascript_modules
( module_name varchar2(100) primary key not null
, source clob not null
View apex-mle-pre-rendering-page.js
console.log(variable1); // error: variable1 is not defined
console.log(globalThis.variable1); // undefined
console.log(globalThis.variable2); // 200
View apex-mle-ajax.js
In case the browser asynchronously called the server via AJAX,
this is how we can handle that request in JavaScript (MLE)
let response = {};
try {
// execute any business logic here
// dummy response
View apex-mle-after-submit.js
// getting page item values
const empno = apex.env.P1_ID;
const salary = apex.env.P1_SAL;
// executing DML operations
apex.conn.execute('update emp set sal = :sal where empno = :empno', {
sal: salary,
empno: empno 
View apex_202_cke5_js_init_code.js
// followup to this conversation
function(options) {
options.editorOptions.toolbar = {
'|', 'code', 'codeBlock', 'blockQuote',
'|', 'bold', 'italic', 'underline', 'strikethrough', 'fontfamily', 'fontsize', 'RemoveFormat', 'link',
'|', 'numberedList', 'bulletedList', 'outdent', 'indent', 'Alignment',
'|', 'InsertTable', 'fontColor', 'fontBackgroundColor',
'|', 'PageBreak', 'HorizontalLine', 'todoList', 'undo', 'redo'