Error in Jelly script

yasararabath
Tera Contributor

 

Hi ,

 

I am writing a script on UI macro where I have to open a url when I click on the button. All working good except the below line of code where the system is not rendering the below line when the form loads.

Code:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<td align="left">
<button id="createEnq" onClick="onCreateEnq();">Create Enquiry</button>
<script>
function onCreateEnq()
{

var reqFor = g_form.getValue('caller');
var location =g_form.getValue('caller.location');
var reqItem = 'e4595d8edbe8b240a35dba9ffe96197a';
var comments1 = g_form.getValue('short_description');
var comments2 = g_form.getValue('description');
var comments=comments1+comments2;

var bs=g_form.getValue('u_business_service');
var OwnedGroup=getValue('u_owned_by');


var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem +'&amp;sysparm_user=' + reqFor + 'sysparm_location=' + location + 'sysparm_comments=' + comments+'sysparm_bs='+bs+'sysparm_OwnedGroup='+OwnedGroup;

window.open(url)

}

</script>
</td>
</j:jelly>


Error while loading form: The reference to entity "sysparm_user" must end with the ';' delimiter.

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem +'&amp;sysparm_user=' + reqFor + '&amp;sysparm_location=' + location + '&amp;sysparm_comments=' + comments+'&amp;sysparm_bs='+bs+'&amp;sysparm_OwnedGroup='+OwnedGroup; 

 

Could you please help me on this ASAP?

Regards,

Yasar 

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

 

Change this to 

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem +'&amp;sysparm_user=' + reqFor + '&amp;sysparm_location=' + location + '&amp;sysparm_comments=' + comments+'&amp;sysparm_bs='+bs+'&amp;sysparm_OwnedGroup='+OwnedGroup; 


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

 

Change this to 

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem +'&amp;sysparm_user=' + reqFor + '&amp;sysparm_location=' + location + '&amp;sysparm_comments=' + comments+'&amp;sysparm_bs='+bs+'&amp;sysparm_OwnedGroup='+OwnedGroup; 


Please mark this response as correct or helpful if it assisted you with your question.

What was changed?

SanjivMeher
Kilo Patron
Kilo Patron

Can you try this instead

 

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem +'&sysparm_user=' + reqFor + '&sysparm_location=' + location + '&sysparm_comments=' + comments+'&sysparm_bs='+bs+'&sysparm_OwnedGroup='+OwnedGroup; 


Please mark this response as correct or helpful if it assisted you with your question.

Mark Stanger
Giga Sage

This seems to work fine for me, but if you are having issues I'd guess it has to do with the '&amp;' pieces in your 'url' variable string.  That typically needs to be escaped properly to work in Jelly.  I'd try replacing each of those with '${AMP}' or '$[AMP]' and see if that helps.

Check out this doc for more details.

https://docs.servicenow.com/bundle/kingston-application-development/page/script/general-scripting/concept/c_ExtensionsToJellySyntax.html#ariaid-title15