Cannot read property "length" from null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 01:45 PM
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.
- Labels:
-
Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 01:55 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 02:04 PM - edited 10-04-2022 02:06 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 03:20 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 10:16 AM
@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.
result: