Visual Task Board - Avoid automatic Lane creation on a board created from script

Federico Giuli1
Tera Contributor

Hi,

 

I have this script that creates a visual task board and only a set of lanes. The goal is show in this board only the states related to the tables rm_story, rm_scrum_task, and u_bug (custom table) that extend the task table.

So this is the script

 

var taskTable = "task"
 
var vtbId = "";
var vtbGr = new GlideRecord('vtb_board');
var index = 0;
  //  if (!vtbId || !vtbGr.get(vtbId)) {
        vtbGr = new GlideRecord('vtb_board');
        vtbGr.initialize();
        vtbGr.name = "prova task board"
        vtbGr.owner = gs.getUserID();
        vtbGr.table = taskTable;
        vtbGr.filter = 'numberSTARTSWITHBUG^ORnumberSTARTSWITHSTR^ORnumberSTARTSWITHSTSK^EQ';
        vtbGr.field = 'state';
        vtbGr.card_limit = 1000;
        vtbGr.stream_limit = 50;
        vtbGr.show_list_toggle = true;
        vtbGr.background_color = 'vtb-board-color-1';
        vtbId = vtbGr.insert();


 
        //If using field kanban which is the default lanes we must create these lanes
        if (vtbGr.field == 'state') {
            var lanes = get_lanes();
            for(var i in lanes){
                index += 1;
                var laneGr = new GlideRecord('vtb_lane');
                laneGr.initialize();
                laneGr.board = vtbId;
                laneGr.name = i;
                laneGr.value = lanes[i];
                laneGr.order = index;
                laneGr.insert();
            }
        }
        //Setting the user prefrence
       // gs.getUser().setPreference('vtb.assigned.to.me' + taskTable, vtbId);
 //   }
   // g_processor.redirect('$vtb.do?sysparm_board=' + vtbId);



function get_lanes(){
    var obj = {};

    var grSysChoice = new GlideRecord('sys_choice');
    grSysChoice.addEncodedQuery("elementSTARTSWITHstate^nameSTARTSWITHu_bug^ORnameSTARTSWITHrm_story^ORnameSTARTSWITHrm_scrum_task");
    grSysChoice.query();


    var tmp = "";
    var label = "";
    var value = "";
    var table = "";

    while (grSysChoice.next()) {
        table = grSysChoice.getValue('name');
        value = grSysChoice.getValue('value');
        label = grSysChoice.getValue('label');

        if(obj[label] == undefined)
            obj[label] = "";
        else obj[label] += "," 

        tmp = obj[label];
        tmp +=  table + ":" + value;
        obj[label] = tmp

    }
    return obj;
}

 

Initially the board is succesfully created with the correct lanes, however when I click on "show board" all the other states are automatically added as lanes. Is there a way to avoid this behaviour?

 

Let me know,

Thanks in advance,

Federico

0 REPLIES 0