HTML Field Updates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 01:42 PM
I have 4 html fields that have historic information in them. I have created a new html field so I can combine the historic information from the 4 html fields into that one field. I am stuck on creating the fix script to execute.
Right now its only populating from one field but not the rest, and I am getting no error message that says it's wrong but not sure what i need to add or updated. It's also not displaying the titles, i.e. Customer Objectives
p.s - yes i realize it's u_tablename, i did that on purpose for this post 🙂
var gr = new GlideRecord('u_tablename);
gr.addEncodedQuery('number=SVOTT0001641'); //using encoded query to only test one record at a time
var summary = gr.addQuery('u_customer_objectives', true); //defining the fields, only using 3 fields for now
summary.addOrCondition('u_solution_strategy', true);
summary.addOrCondition('u_solution_metrics', true);
gr.query();
while (gr.next()) {
if (gr.u_summary == '') {
gr.u_summary = gr.u_customer_objectives;
gr.u_summary = gr.u_solution_strategy;
gr.u_summary = gr.u_solution_metrics;
} else {
gr.u_summary = "/nCustomer Objectives:" + u_customer_objectives + "\nSolution Strategy:" + u_solution_strategy + "\nSolution Metrics:" + u_solution_metrics;
}
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 01:57 PM
Hello,
It's because you keep reassigning "gr.u_summary" over and over to the different field values. So you're not adding to it, you're simply replacing the field value with each field with every time ending with gr.u_solution_metrics value.
Instead, you'd want to use something like what you have in your else part of the script.
Unfortunately, you cover 2 scenarios in your script but you've given us no information at all as to what your test case has been. Has it been for both scenarios (where u_summary has a value first or no)? Please always give as much information as you can when posting questions on the forums.
In any case, please consider adjusting your script and use similar functionality as to your else part of the script and you'll see what I'm talking about.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 02:33 PM
Hello,
Thanks for a speedy reply Allen. The u_summary field has no information in it. Currently there are 4 html fields, and moving forward, the requirement is just to have one html field so users can write in whatever they need. The purpose of the fix script is to ensure that the data from previous/historic records gets populated in the new field.
My scripting is not the best I have to admit, but I am trying. I will use your suggestion and update accordingly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 03:31 PM - edited 03-20-2023 03:32 PM
Hi,
So if you're trying to run this as a fix script and just want to populate the u_summary field with any field information in those other HTML fields, then this would work:
var gr = new GlideRecord('u_tablename');
gr.addEncodedQuery('number=SVOTT0001641'); //using encoded query to only test one record at a time
gr.query();
while (gr.next()) {
var string = "Customer Objectives:" + gr.getValue('u_customer_objectives') + "\nSolution Strategy:" + gr.getValue('u_solution_strategy') + "\nSolution Metrics:" + gr.getValue('u_solution_metrics');
gr.setValue('u_summary', string);
gr.update();
}
So in that test record, clear out the summary field, then run this and see what you think.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!