Search
 
SCRIPT & CODE EXAMPLE
 

CSS

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;
}
Comment

PREVIOUS NEXT
Code Example
Css :: decroation of title using css 
Css :: full calendar custom css 
Css :: uytutyu 
Css :: ipad css media query 
Css :: inclure html ds html avec <object -- et style css 
Css :: reorder images in mobile web developer 
Css :: chrome console remove css dark mode 
Css :: css design guideline 
Css :: font sixe sss 
Css :: tailwind simle navbar" 
Css :: how to link css stylesheet python django 
Css :: how can i make a menu bar appear by clicking an icon? in css? 
Css :: <asp:FileUpload ID="Fu_Result" runat="server" Width="250px" CssClass="inputfile" / 
Css :: on frontend grivity form css not load 
Css :: placeholder color default 
Css :: css float and clear 
Css :: css select first word 
Css :: bootstrap.min.css code download 
Typescript :: remove &nbsp from string in typescript 
Typescript :: first principle in testing 
Typescript :: javax.validation.constraints does not exist 
Typescript :: typescript submit event 
Typescript :: google sheets remove characters from string 
Typescript :: split list into lists of equal length python 
Typescript :: cra template-typescript cmd 
Typescript :: adonis select 
Typescript :: adding paragraphs with foreach in angular docx.js 
Typescript :: are loop increments private in openmp 
Typescript :: ionic maintain order of object properties 
Typescript :: how to check what have you installed globally linux 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =