I have create a custom js file in a clientlib with category dam.gui.coral.metadataeditor. I have added the below code to my JS:
"use strict";
use(function () {
var path = currentPage.path;
});
When I open the Properties page for my asset this JS loads. But I am seeing a console error:
Uncaught ReferenceError: Use is not defined at <myjsfile.js:2>
I am not able to use the Use Api in my javascript
Solved! Go to Solution.
Views
Replies
Total Likes
currentPage is a server side object which can be only used in HTL JavaScript Use-API, Rhino JavaScript engine will convert JavaScript and only understands HTL global objects. You can not use HTL global object in custom Client Library JavaScript.
Did you try restarting this instance? I see other people are facing this issue. check below link
Views
Replies
Total Likes
The js use API execute at the server-side and we use this in components business logic, but I never tried this by adding category dam.gui.coral.metadataeditor, and in this case, based on my understanding you are calling use API in metadata validation, I think this will not work. you need to use JS to get the page path and other business logic.
This is my understanding let's hear from other community members
Views
Replies
Total Likes
You need to use jquery selectors to get the value, check this article to get some idea https://medium.com/@theopendle/aem-custom-metadata-forms-for-assets-8c6597205f9d
Views
Replies
Total Likes
currentPage is a server side object which can be only used in HTL JavaScript Use-API, Rhino JavaScript engine will convert JavaScript and only understands HTL global objects. You can not use HTL global object in custom Client Library JavaScript.
Views
Replies
Total Likes
Views
Likes
Replies