06-30-2017 04:59 AM
Hi,
I have built a project using Alfresco SDK 3.0 and tried to override the getShareServices() in the share-header.lib.js file. I created the modified share-header.lib.js in the following directory of SDK folder sites-webscripts/
sites-webscripts/com/alfresco/share/imports/
and my extension file is like as follow
<module>
<id>custom shareService</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.imports</targetPackageRoot>
<sourcePackageRoot>com.alfresco.share.imports</sourcePackageRoot>
<alwaysApply>
<webscript>share-header</webscript>
</alwaysApply>
</customization>
</customizations>
</module>
But the changes are not applied, though the new module is getting registered. Do I need to add anything more?
Thanks.
06-30-2017 06:17 AM
The targetPackageRoot is incorrect. You are trying to target library scripts, but the targetPackageRoot is actually meant to target the actual web scripts that render a particular page.
Also, you cannot override a function (getShareServices) using the "customization" approach. The original code will already have been run by the point your code is called. Your customisation is supposed to act like a post-processor and modify the result of the original code (in the web script model).
11-21-2020 02:55 PM
I have achived same goal as below:
1) Extention model.
<extension>
<modules>
<module>
<id>Add custom menu item to header</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
<sourcePackageRoot>org.alfresco.share.imports</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
2) You can override your getShareServices() by updating in the share-header.lib.js
3) Place your updated share-header.lib.js in same folder where share-header.get.js and update path like this where your share-header.lib.js reside in the share-header.get.js
<import resource="classpath:/alfresco/web-extension/site-webscripts/org/alfresco/share/imports/share-header.lib.js">
Explore our Alfresco products with the links below. Use labels to filter content by product module.