Make variables dynamically available on tasks

PHOTO EMBED

Wed Jul 13 2022 20:24:23 GMT+0000 (Coordinated Universal Time)

Saved by @taracatac #javascript #reference #qualifier

//On display BR to capture scratchpad 
//HH - Set g_scratchpad for sc_task
//Capture the current wf activity to use in client side scripts
(function executeRule(current, previous /*null when async*/) {
    g_scratchpad.wf_activity = current.wf_activity.getDisplayValue();
})(current, previous)

//UI Policy on sc_task table to dynamically show/hide/make mandatory
//HH - Make variables visible and mandatory for tasks on RITM -  Settlement Vendor
//execute if true
function onCondition() {
    if (g_scratchpad.wf_activity == 'Create Task for Accounts Payable') {
        g_form.setVisible('u_1099_misc_form_legal_name', true);
        g_form.setVisible('u_1099_code', true);
        g_form.setMandatory('u_1099_code', true);
        g_form.setMandatory('u_1099_misc_form_legal_name', true);
    }
}
if (g_scratchpad.wf_activity == 'Create Task for Data Integrity') {
    g_form.setVisible('u_1099_code', true);
    g_form.setVisible('u_1099_misc_form_legal_name', true);
    g_form.setReadOnly('u_1099_code', true);
    g_form.setReadOnly('u_1099_misc_form_legal_name', true);
    g_form.setVisible('vendor_number', true);
    g_form.setMandatory('vendor_number', true);
}

if (g_scratchpad.wf_activity == 'Create Task for Treasury') {
    g_form.setVisible('u_1099_code', false);
    g_form.setVisible('u_1099_misc_form_legal_name', false);
    g_form.setMandatory('u_1099_code', false);
    g_form.setMandatory('u_1099_form_legal_name', false);
    g_form.setVisible('vendor_number', false);
    g_form.setMandatory('vendor_number', false);
}

//execute if false
function onCondition() {
    g_form.setVisible('u_1099_code', false);
    g_form.setVisible('u_1099_misc_form_legal_name', false);
    g_form.setMandatory('u_1099_code', false);
    g_form.setMandatory('u_1099_form_legal_name', false);
    g_form.setVisible('vendor_number', false);
    g_form.setMandatory('vendor_number', false);
}
content_copyCOPY

Create on display BR to capture scratchpad