Does Madrid support JavaScript string interpolation?

thomaskennedy
Tera Guru

I'm setting the params on a SoapMessage and I have one case where one param declared in my soapmessage may consist of the markup for multiple child elements.

SoapMessage:

</Narratives>
<EventValues>${event.rows}</EventValues>
<Polices>

The data may look like so:

<EventValue sku="abc" upc="12345"/>
<EventValue sku="def" upc="5678"/>

So I would like to do this:

var rows = (an array of objects)
var rows_data = "";
for(var index = 0; index < rows.length; index++) {
	var row = rows_data[index]; 
	rows_data += `<EventValue 
 		sku="${row[this.EVENT_VALUE_SKU]}" 
 		upc="${row[this.EVENT_VALUE_UPC]}" 
 		.../>`;
	}
s.setStringParameterNoEscape( "event.rows", rows_data);

But the editor says there is an illegal character on the line where my template begins. I believe it does not support interpolation in this context. Is this correct, and is there a way around it?

1 ACCEPTED SOLUTION

To the best of my knowledge (and ability to find) ServiceNow does not support what you are describing. 

From what I can find, ServiceNow only supports to to ES5: 

https://docs.servicenow.com/bundle/newyork-application-development/page/script/JavaScript-engine-upg...

and from what I can find, template literals were introduced in ES6: 

https://developers.google.com/web/updates/2015/01/ES6-Template-Strings

So, I believe the answer is no, this is not supported currently in ServiceNow. 

If this was helpful, or correct, please be kind and remember to mark appropriately!

Michael Jones - Cloudpires

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

5 REPLIES 5

Sumanth16
Kilo Patron

Hi thomas ,

 

I  am not sure this is exact answer (or) not

 

Servicenow using ES5 mode 

Please refer below link:

https://docs.servicenow.com/bundle/newyork-application-development/page/script/JavaScript-engine-upg...

 

 

As per this article string interpolation started from ES6 mode:

Please refer below link:

 

https://campushippo.com/lessons/how-to-do-string-interpolation-with-javascript-7854ef9d\

 

If it helps please mark it as helpful

 

Thanks,

Sumanth