Skip to content

Instantly share code, notes, and snippets.

View stefandobre's full-sized avatar
💭
probably working on an APEX Plugin

Stefan Dobre stefandobre

💭
probably working on an APEX Plugin
View GitHub Profile
@stefandobre
stefandobre / actions.js
Last active September 26, 2019 06:02
Finding actions to invoke/get/set/toggle in the Interactive Grid
var igId = 'emp';
var region = apex.region(igId);
var actions = region.call('getActions');
var actionList = [... new Set(actions.list().map(a => a.name))];
var toInvoke = [];
var toGetSet = [];
var toToggle = [];
for(i in actionList){
var action = actions.lookup(actionList[i]);
create table javascript_modules
( module_name varchar2(100) primary key not null
, source clob not null
);
// calling our custom requireModule function
const qrcode = requireModule('qrcode');
// library specific options
const code = qrcode(4, 'L');
code.addData(apex.env.P1_QR_DATA);
code.make();
// saving the base64 result into a page item of type Display Image
apex.env.P1_QR_CODE = code.createDataURL(4);
// 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 
});
/*
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
apex.conn.execute();
// dummy response
let variable1 = 100;
globalThis.variable2 = 200;
console.log(variable1); // error: variable1 is not defined
console.log(globalThis.variable1); // undefined
console.log(globalThis.variable2); // 200
declare
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;
begin
/* store the name and location of each library that is to be imported */
l_modules('qrcode') := 'https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.4/qrcode.min.js';
l_modules('validator') := 'https://cdnjs.cloudflare.com/ajax/libs/validator/13.5.2/validator.min.js';
l_modules('marked') := 'https://cdnjs.cloudflare.com/ajax/libs/marked/1.2.9/marked.min.js';
// followup to this conversation https://stefandobre.com/a-closer-look-at-the-rich-text-editor-of-orclapex-20-2/
function(options) {
options.editorOptions.toolbar = {
items:[
'heading',
'|', 'code', 'codeBlock', 'blockQuote',
'|', 'bold', 'italic', 'underline', 'strikethrough', 'fontfamily', 'fontsize', 'RemoveFormat', 'link',
'|', 'numberedList', 'bulletedList', 'outdent', 'indent', 'Alignment',
'|', 'InsertTable', 'fontColor', 'fontBackgroundColor',
'|', 'PageBreak', 'HorizontalLine', 'todoList', 'undo', 'redo'
const marked = requireModule('marked');
// library-specific options
marked.setOptions({
headerIds: false
});
apex.env.P5_HTML = marked(apex.env.P5_MARKDOWN);