I'm having a hard time getting
the current url in the share.
I'm adding a script in Repository > Data Dictionary > Scripts
I need to capture the name of the site I'm on or the current url
but an error is coming.
" 254 KB (Failure: Failed to execute script 'workspace://SpacesStore/9c2b6207-ed5a-48f1-9fa9-350616033cc0': 03190438 ReferenceError: "window" is not defined. (workspace://SpacesStore/9c2b6207-ed5a-48f1-9fa9-350616033cc0#9))
"
Thank you very much in advance.
Solved! Go to Solution.
@hernanisaurelio You can use the root scoped object "document" and then get the site name.
Example: get-sitename-folder-rule.js (here 'document' is the folder node where you are creating the folder rule)
logger.log("FolderDisplayPath where rule is created: "+ document.displayPath);
var siteName = document.getSiteShortName(); logger.log("SiteName: "+ siteName);
//do whatever you want with the site name
Then you can use siteService.getSite() or siteService.getSiteInfo() to pull more info about site as needed, you will get Site or SiteInfo objects to play around.
example:
logger.log("FolderDisplayPath where rule is created: "+ document.displayPath); //get site short name from folder nodeRef var siteShortName = document.getSiteShortName(); logger.log("SiteShortName: "+ siteShortName); var siteInfo = siteService.getSiteInfo(siteShortName); logger.log("Site Display Title: "+siteInfo.getTitle()); //Or getSite var site = siteService.getSite(siteShortName); logger.log("Site Display Title: "+site.getTitle());
Hope this helps.
AFAIK, window object wont work in repository webscript/script. Not sure though.
If you can elobrate the use case and requirement as to what exactly you are trying to do then some potential solution can be thought of.
Mr. abhinav mishra
thank you very much for your time.
I intend to run this script in a specific folder on a site
How can I capture just the current site name in my script.
Thank you very much in advance
@hernanisaurelio You can use the root scoped object "document" and then get the site name.
Example: get-sitename-folder-rule.js (here 'document' is the folder node where you are creating the folder rule)
logger.log("FolderDisplayPath where rule is created: "+ document.displayPath);
var siteName = document.getSiteShortName(); logger.log("SiteName: "+ siteName);
//do whatever you want with the site name
Then you can use siteService.getSite() or siteService.getSiteInfo() to pull more info about site as needed, you will get Site or SiteInfo objects to play around.
example:
logger.log("FolderDisplayPath where rule is created: "+ document.displayPath); //get site short name from folder nodeRef var siteShortName = document.getSiteShortName(); logger.log("SiteShortName: "+ siteShortName); var siteInfo = siteService.getSiteInfo(siteShortName); logger.log("Site Display Title: "+siteInfo.getTitle()); //Or getSite var site = siteService.getSite(siteShortName); logger.log("Site Display Title: "+site.getTitle());
Hope this helps.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.