Cannot read property "length" from null

GD11
Tera Expert

I have written a script to find some specific content from all HTML fields from knowledge articles but getting below error when there is not specific data in one of the field, not sure what should I write so that it can run only when there is at least 1 matching record in 1 of the HTML field. 

 

GovindDhande_1-1664916255101.png

 

6 REPLIES 6

Bert_c1
Kilo Patron

You need to add 'debug' such as using gs.info() to display values of your variables. I tried your logic as below and get an execution error:

Evaluator: com.glide.script.RhinoEcmaError: "txt" is not defined.
   script : Line(4) column(0)
      1: var gr3 = new GlideRecord('u_idea');
      2: gr3.query();
      3: while (gr3.next()) {
==>   4:   var str=gr3[txt];
      5:   gs.info("str = " + str + ".");
      6: }

Where is 'txt' defined?

hi @Bert_c1 you can use any field name instead of txt.  here is the full code, I am trying to find the HTML fields on all article templates and use those HTML fields to find the data they contain. 

GovindDhande_0-1664917444532.png

 

 

Bert_c1
Kilo Patron

My comment is on your first example, the odd syntax to access the record's fields 

 var str = gr3[txt];

.  Your 2nd post has 'gr1' and 'gr2' objects. I do not see any problem that code.

 

I can discuss the dictionary aspect, tables can have field that are "html" type. to determine which fields on your table are of that type. query the sys_dictionary for your table and fields of type html

 

https://[instance]/sys_dictionary_list.do?sysparm_query=internal_type%3Dhtml&sysparm_view= 

 

add a filter condition on 'Table' to see just those for your table.

@Bert_c1 I have used gr3[txt] because gr3.txt is returning undefined result. so I used object. I tried gliderecord on sys_dictionary table and it is same error there as well.

 

GovindDhande_3-1664990052602.pngGovindDhande_4-1664990102039.png

 

result:

 

GovindDhande_5-1664990181857.png