Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to map MRVS to an html field

Komaldeep
Tera Contributor

Hello Everyone, 
I want to thank you in advance for solving my query.

 I want to map MRVS with an HTML field in the form.

I have written the following code but was not able to achieve the functionality.

I wrote the following code in the Record producer script 

var keyw = JSON.parse(producer.mrvs_name);
var mrvs_val_table = ' ';
 var keywrd = new GlideRecord('table name');
keywrd.initialize();
for (var i = 0; i < keyw.length; i++) {
  //gs.addInfoMessage(keyw[i].social_impact_assessment); 
   mrvs_var_table = '<table>'+'<tr>' +
       '<td>' + keyw[i].social_impact_assessment + '</td>' +
       '<td>' + keyw[i].entrepreneur_thinking + '</td>' +
       '<td>' + keyw[i].digital_inclusion + '</td>' +
       '</tr>'+'</table>';
    
}
  
  keywrd.setValue('u_keywords', mrvs_val_table);
    keywrd.insert();

1 ACCEPTED SOLUTION

Vasantharajan N
Tera Sage

Please use the below code for your requirement.

var arr = producer.mrvs_name;
var desc = '<table border="1px"><tbody><tr><th>Social Impact Assessment</th><th>Entrepreneur Thinking</th><th>Digital Inclusion</th></tr>';
for (var i = 0; i < arr.getRowCount(); i++) {
    desc += '<tr><td>' + arr.getRow(i).social_impact_assessment + "</td><td>" + arr.getRow(i).entrepreneur_thinking + "</td><td>" + arr.getRow(i).digital_inclusion + "</td></tr>";
}
desc += '</table>';

var keywrd = new GlideRecord('table name');
keywrd.initialize();
keywrd.setValue('u_keywords', desc);
keywrd.insert();

Thanks & Regards,
Vasanth

View solution in original post

1 REPLY 1

Vasantharajan N
Tera Sage

Please use the below code for your requirement.

var arr = producer.mrvs_name;
var desc = '<table border="1px"><tbody><tr><th>Social Impact Assessment</th><th>Entrepreneur Thinking</th><th>Digital Inclusion</th></tr>';
for (var i = 0; i < arr.getRowCount(); i++) {
    desc += '<tr><td>' + arr.getRow(i).social_impact_assessment + "</td><td>" + arr.getRow(i).entrepreneur_thinking + "</td><td>" + arr.getRow(i).digital_inclusion + "</td></tr>";
}
desc += '</table>';

var keywrd = new GlideRecord('table name');
keywrd.initialize();
keywrd.setValue('u_keywords', desc);
keywrd.insert();

Thanks & Regards,
Vasanth