Setting by default value of HTML field

kumariDiksha
Tera Contributor

Hi All, 

 

I have to set by default HTML content in HTML variable. 

I have to create a table like below. 

 

kumariDiksha_0-1707396386043.png

 

this HTMl field is in my Sc_task level. 

 

I have created onload sclient script on sc_task level. 

 

and tried this. 

 

var mySourceCode = " source code pasted here ";

g_form.setValue('backend HTML variable',mySourceCode);

 

but it is giving error in this line "var mySourceCode = " source code pasted here "; ". It's showing unterminated string constant. 

 

How to fix this scenario?

 

 

1 ACCEPTED SOLUTION

@kumariDiksha Here is the updated script which you should use.

 

function onLoad() {
//Type appropriate comment here, and begin script below

var mySourceCode = '<p><strong>Fill the details below</strong></p> <table style="border-collapse: collapse; width: 100.957%; height: 153.958px;" border="1"> <tbody> <tr style="height: 46.1875px;"> <td style="width: 9.37067%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">vendor/pricing</span></strong></span></td> <td style="width: 8.11567%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Initial Price&nbsp;</span></strong></span></td> <td style="width: 7.19534%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Final Price</span></strong></span></td> <td style="width: 10.2073%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Savings</span></strong></span></td> <td style="width: 9.37067%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Lowest Bidder</span></strong></span></td> <td style="width: 17.068%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Recommended bidder</span></strong></span></td> <td style="width: 19.076%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Reason for recommendation</span></strong></span></td> <td style="width: 8.45034%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">SAN Active</span></strong></span></td> <td style="width: 11.1277%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Remarks</span></strong></span></td> </tr> <tr style="height: 15.3958px;"> <td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">vendor 1</span></strong></span></td> <td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td> <td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td> <td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td> <td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td> <td style="width: 17.068%; height: 15.3958px;">&nbsp;</td> <td style="width: 19.076%; height: 15.3958px;">&nbsp;</td> <td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td> <td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td> </tr> <tr style="height: 15.3958px;"> <td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Vendor 2</span></strong></span></td> <td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td> <td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td> <td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td> <td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td> <td style="width: 17.068%; height: 15.3958px;">&nbsp;</td> <td style="width: 19.076%; height: 15.3958px;">&nbsp;</td> <td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td> <td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td> </tr> <tr style="height: 15.3958px;"> <td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Vendor 3</span></strong></span></td> <td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td> <td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td> <td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td> <td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td> <td style="width: 17.068%; height: 15.3958px;">&nbsp;</td> <td style="width: 19.076%; height: 15.3958px;">&nbsp;</td> <td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td> <td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td> </tr> </tbody> </table>';
g_form.setValue('u_vendor_name',mySourceCode);
}

Hope this helps.

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@kumariDiksha It looks like your HTML source code is not wrapped in quotes correctly and hence the string parsing is throwing the error.

 

Could you please paste the code here so that I can suggest the changes?

Hi @Sandeep Rajput

 

this is the onload client script that I have written. 

 

function onLoad() {
//Type appropriate comment here, and begin script below

var mySourceCode = '<p><strong>Fill the details below</strong></p>
<table style="border-collapse: collapse; width: 100.957%; height: 153.958px;" border="1">
<tbody>
<tr style="height: 46.1875px;">
<td style="width: 9.37067%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">vendor/pricing</span></strong></span></td>
<td style="width: 8.11567%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Initial Price&nbsp;</span></strong></span></td>
<td style="width: 7.19534%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Final Price</span></strong></span></td>
<td style="width: 10.2073%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Savings</span></strong></span></td>
<td style="width: 9.37067%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Lowest Bidder</span></strong></span></td>
<td style="width: 17.068%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Recommended bidder</span></strong></span></td>
<td style="width: 19.076%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Reason for recommendation</span></strong></span></td>
<td style="width: 8.45034%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">SAN Active</span></strong></span></td>
<td style="width: 11.1277%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Remarks</span></strong></span></td>
</tr>
<tr style="height: 15.3958px;">
<td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">vendor 1</span></strong></span></td>
<td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td>
<td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td>
<td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td>
<td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td>
<td style="width: 17.068%; height: 15.3958px;">&nbsp;</td>
<td style="width: 19.076%; height: 15.3958px;">&nbsp;</td>
<td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td>
<td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td>
</tr>
<tr style="height: 15.3958px;">
<td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Vendor 2</span></strong></span></td>
<td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td>
<td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td>
<td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td>
<td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td>
<td style="width: 17.068%; height: 15.3958px;">&nbsp;</td>
<td style="width: 19.076%; height: 15.3958px;">&nbsp;</td>
<td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td>
<td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td>
</tr>
<tr style="height: 15.3958px;">
<td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Vendor 3</span></strong></span></td>
<td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td>
<td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td>
<td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td>
<td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td>
<td style="width: 17.068%; height: 15.3958px;">&nbsp;</td>
<td style="width: 19.076%; height: 15.3958px;">&nbsp;</td>
<td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td>
<td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td>
</tr>
</tbody>
</table>';
g_form.setValue('u_vendor_name',mySourceCode);

}

@kumariDiksha Here is the updated script which you should use.

 

function onLoad() {
//Type appropriate comment here, and begin script below

var mySourceCode = '<p><strong>Fill the details below</strong></p> <table style="border-collapse: collapse; width: 100.957%; height: 153.958px;" border="1"> <tbody> <tr style="height: 46.1875px;"> <td style="width: 9.37067%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">vendor/pricing</span></strong></span></td> <td style="width: 8.11567%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Initial Price&nbsp;</span></strong></span></td> <td style="width: 7.19534%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Final Price</span></strong></span></td> <td style="width: 10.2073%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Savings</span></strong></span></td> <td style="width: 9.37067%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Lowest Bidder</span></strong></span></td> <td style="width: 17.068%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Recommended bidder</span></strong></span></td> <td style="width: 19.076%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Reason for recommendation</span></strong></span></td> <td style="width: 8.45034%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">SAN Active</span></strong></span></td> <td style="width: 11.1277%; height: 46.1875px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Remarks</span></strong></span></td> </tr> <tr style="height: 15.3958px;"> <td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">vendor 1</span></strong></span></td> <td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td> <td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td> <td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td> <td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td> <td style="width: 17.068%; height: 15.3958px;">&nbsp;</td> <td style="width: 19.076%; height: 15.3958px;">&nbsp;</td> <td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td> <td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td> </tr> <tr style="height: 15.3958px;"> <td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Vendor 2</span></strong></span></td> <td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td> <td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td> <td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td> <td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td> <td style="width: 17.068%; height: 15.3958px;">&nbsp;</td> <td style="width: 19.076%; height: 15.3958px;">&nbsp;</td> <td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td> <td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td> </tr> <tr style="height: 15.3958px;"> <td style="width: 9.37067%; height: 15.3958px;"><span style="background-color: #ffffff;"><strong><span style="color: #000000; font-size: 8pt; background-color: #ffffff;">Vendor 3</span></strong></span></td> <td style="width: 8.11567%; height: 15.3958px;">&nbsp;</td> <td style="width: 7.19534%; height: 15.3958px;">&nbsp;</td> <td style="width: 10.2073%; height: 15.3958px;">&nbsp;</td> <td style="width: 9.37067%; height: 15.3958px;">&nbsp;</td> <td style="width: 17.068%; height: 15.3958px;">&nbsp;</td> <td style="width: 19.076%; height: 15.3958px;">&nbsp;</td> <td style="width: 8.45034%; height: 15.3958px;">&nbsp;</td> <td style="width: 11.1277%; height: 15.3958px;">&nbsp;</td> </tr> </tbody> </table>';
g_form.setValue('u_vendor_name',mySourceCode);
}

Hope this helps.

Hi Sandeep,

By default it is setting the value but if I update and save the information on the ticket it is not saving the information because of the onload script. Is there any other way to set the information and if anyone update the information it should show updated information?