Horje
get variable containers Code Example
get variable containers
//init
var CATALOG_ITEM_SYS_ID = '', //TODO: REPLACE THIS WITH THE SYS_ID OF THE CATALOG ITEM
    i,
    currentVar,
    fieldName = 'sys_id',
    varMap = {},
    currentContainer,
    containerLevel = [],
    item = GlideappCatalogItem.get(CATALOG_ITEM_SYS_ID),
    grVariables = item.getVariables();

//For every variable found...
while (grVariables.next()) {

    var varName = grVariables.getValue('name');
    var varSid = grVariables.getValue('sys_id');
    var varType = grVariables.type.getDisplayValue();
    var varQuestion = grVariables.getValue('question_text');
    var varActive = grVariables.getValue('active');

    if (varType === 'Container Start') {
        containerLevel.push(varSid);
    } else if (varType === 'Container End') {
        containerLevel.pop();
    }
    currentContainer = varMap;
    for (i = 0; i < containerLevel.length; i++) {
        if (!currentContainer.hasOwnProperty(containerLevel[i])) {
            currentContainer[containerLevel[i]] = {};
        }
        currentContainer = currentContainer[containerLevel[i]];
    }

    currentContainer[varSid] = new Variable(varName, varSid, varType, varQuestion, varActive);
}

gs.print(JSON.stringify(varMap));

function Variable(varName, varSid, varType, varQuestion, varActive, varOrder) {
    this.varName = varName;
    this.varSid = varSid;
    this.varType = varType;
    this.varQuestion = varQuestion;
    this.varActive = varActive;
    this.varOrder = varOrder;
}




Css

Related
background behind image css Code Example background behind image css Code Example
inherit styles Code Example inherit styles Code Example
easy way raise specificity css Code Example easy way raise specificity css Code Example
css button type Code Example css button type Code Example
php-twig (> 2.9) but 2.6.2-2 Code Example php-twig (> 2.9) but 2.6.2-2 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12