Question about Checklist Formatter

JK1
Giga Expert

Hey guys,

happy new 2018 year to all of you!

As I want to apply given checklist (saved as template) for a particular ticket types, but so far I am failing to do so, is there a way you can do that without just adding a ton of HTML elements into the DOM ? I want to use these as a dynamic checklist, what must be done as a work .

Where are these held? And how can I add such checklist template whenever I would like to?

find_real_file.png

Cheers,

Joro

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Ash, 

these are 2 UI Macros - serach under macros with *check and you'll find them.

 

Cheers,

 

Joro

View solution in original post

15 REPLIES 15

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi Joro,



Not 100% sure what your question is, but here is at least some information that might answer your question.



The formatter is made out of a UI macro and if you follow the trace, it ends up in macro called "checklist_template". In that code it's calling for inline_checklist_template.xml:


find_real_file.png



Sadly this piece is stored in the "black box" and nothing we can customize. Looking at the code which is in Angular, it's having it own directive etc. I wouldn't spend time of copying the code and modify it, since you probably would need to spend a lot of time figuring out what the stuff you can't see does.



But... 😃



If you look at the UI Macro the formatter is calling "inline_checklist_macro". you can see in the code that it's checking if there already is a checklist connected to the record. This meaning that you should be able to automatically attach checklists (template) to an record without the user needs to choose one. But you can't make the checklist change on the fly if the user for example chooses a specific value in a field. But you can create the checklist after the user saves.



For the tables, my guess is the top 3 here is for what you are looking for:


find_real_file.png



For example: Checklist is where the mapping of record -> checklist is saved.



Let me know if there is any other questions about it.


Hey Goran,


that's why you are one of the top brains here


This is what I was needed as a direction - all is done and working fine now.



Thanks again!



Cheers,



Joro


So a small script include is doing what I wanted to achieve - set dynamically different checklist sets depending on data in the template (sys_template) pointed. Hope this will help someone




var dynamicChecklist = Class.create();


dynamicChecklist.prototype = {


initialize: function() {


},


//debugger,


debug: false,



log: function (message) {


var name = 'dynamicChecklist';


if(this.debug) {


gs.log(message,name);


}


},




  /*


  @applyChecklist method


  @param String


  @returns void




  ussed to apply a checklist to a record


  */




  applyChecklist : function(sysid, table, owner, template) {




      var checkList = new GlideRecord("checklist");


      checkList.initialize();


      checkList.document = sysid;


      checkList.table = table;


checkList.owner = owner;


      var chkSysid = checkList.insert();


this.log("applyChecklist : List inserted " + checkList.document);




      var question = this._getQuestionFromTemplate(template).split(",");


      //var sQuestion = question.split(",");


      this.log("applyChecklist : Template is " + question[1]);


      for(var i = 0;i < question.length; i++){


          this._createChecklists(chkSysid, question[i].toString(), i);


          this.log("applyChecklist : calling _createChecklists iteration " + i + " Question -> " + question[i] + " AAAND SYSID of wrapper container " + chkSysid);


      }






  },




  /*


  @_createChecklists internal method


  @param String


  @param String


  @returns void




  used to ...


  */




  _createChecklists : function(sysid, parm, order) {




      var checks = new GlideRecord("checklist_item");


      checks.initialize();


      this.log("_createChecklists : initializing..." + sysid);


      checks.checklist = sysid;


      checks.name = order + ".) " + parm;


checks.order = order;


      checks.insert();




  },




  /*


  @_getQuestionFromTemplate internal method


  @param String


  @returns String




  ussed to ...


  */


  _getQuestionFromTemplate : function(name) {




      var template = new GlideRecord('sys_template');


      template.addQuery('name', name);


      template.query();


      if(template._next()){


          this.log("_getQuestionFromTemplate : Template found   with name -> " + template.name + "   AAAND Short Desc ->   " + template.short_description);




              return template.short_description;


      }




  },




type: 'dynamicChecklist'


};



It will look like this



find_real_file.png


Hello Joro,

Could you please tell me how you implemented this Script Include ? It seems like a perfect match for what I'm trying to do, but I'm afraid it's a little too advanced for me 🙂

I'm creating a Release record from a change_task UI Action. I'd like to push the same Checklist for every Release record created that way. Getting it to work from a BR would also work for me.

Thanks for your help !

Florian