AnsweredAssumed Answered

How to get current site URL to use in AAAR?

Question asked by os.cerna on Apr 11, 2017

Hello everyone,

I have a report(AAAR_Menu.report.bibliotecaArchivos) that needs to change parameters depending on which site it is called, I have looked into the AAAR source code for Dashboards and made this changes to the AAAR.get.js file,  especially on the getAnalyticGroupSettings function(i also modified the get.config.xml so AAAR can display my report):


function getAnalyticGroupSettings(dashletConfig, groupType) {

if (typeof dashletConfig != "xml") {
return [];
}

var result = [];
for each (var link in dashletConfig.link)
{
if(link.@labelId.toString()==="AAAR_Menu.report.bibliotecaArchivos"){

 

var siteName=Alfresco.constants.SITE;
var posF=siteName.lastIndexOf("/");
var posI=siteName.indexOf("site")+5;
siteName=siteName.slice(posI,posF);
result[result.length] = {
type : groupType,
icon : link.@icon.toString(),
label : link.@labelId.toString(),
url : link.@url.toString().concat("?sitio=",siteName),
groups : link.@permits.toString().split(",")
};
}else{
result[result.length] = {
type : groupType,
icon : link.@icon.toString(),
label : link.@labelId.toString(),
url : link.@url.toString(),
groups : link.@permits.toString().split(",")
};
};
}

return result;
}

 

As you see i wanted to get the current site name via an Alfresco constant but when i run Alfresco this error appears: 03110001 Failed to execute script 'classpath*:alfresco/web-extension/site-webscripts/com/fcorti/AAAR/components/dashlet/AAAR.get.js': 03110000 ReferenceError: "Alfresco" is not defined. (file:/C:/Alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/com/fcorti/AAAR/components/dashlet/AAAR.get.js#15)

I think the issue is that i am trying to get data that is within client-side Javascript and using it on a server-side Javascript, but really i do not know how to do it.

Thanks a lot

Outcomes