Service Portal: Javascript error in your browser console
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 02:14 AM
Hello!
We have a catalog client script that uses $j. This works in the backend but in the Service Portal, it shows the error below.
Is there an alternative of using $j in a catalog client script that works in both backend and Service Portal? The client script is:
$j('#loc).change(function() {
var locVal = $j('#loc').val();
locVal = locVal .substring(0,locVal.indexOf(':'));
g_form.setValue('location',locVal);
});
$j('#zipcode').change(function() {
var zipcodeVal = $j('#zipcode').val();
zipcodeVal = zipcodeVal.substring(0,zipcodeVal.indexOf(':'));
g_form.setValue('zipcode',zipcodeVal);
});
}
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 05:42 AM
Hi @ramirch ,
you can use the jQuery keyword instead of $j in your client script to make it work in both backend and Service Portal.
Here's an updated version of your client script that uses jQuery instead of $j:
jQuery(document).ready(function() {
jQuery('#loc').change(function() {
var locVal = jQuery('#loc').val();
locVal = locVal.substring(0, locVal.indexOf(':'));
g_form.setValue('location', locVal);
});
jQuery('#zipcode').change(function() {
var zipcodeVal = jQuery('#zipcode').val();
zipcodeVal = zipcodeVal.substring(0, zipcodeVal.indexOf(':'));
g_form.setValue('zipcode', zipcodeVal);
});
});
Regards,
Shravan
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 10:02 PM
@Sai Shravan Unfortunately this did now work. I'm still getting the Javascript error. 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 04:40 AM - edited 03-08-2023 04:40 AM
Hi @ramirch,
Can you Inspect (Just right-click on any website's area and choose Inspect. You can also use your keyboard shortcut - Ctrl+Shift+I) on the browser, navigate to console and check which line is throwing the error.
Regards,
Shravan
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 05:26 AM
@Sai Shravan This is the error when I used Inspect: TypeError: jQuery is not a function