0

I'm trying to make a webscript on Alfresco Share (and potentially a dashlet) that uses/calls a webscript on the Repository tier. I know I need a description XML file, a javascript and a result page being HTML or JSON. My question is what should be in those files?

This what I have compiled from various sources in the interwebs ;)

Desc:

<webscript>
   <shortname>Some name</shortname>
   <description>Some description</description>
   <family>dashlet</family>
   <url>/components/dashlets/upload/fileupload</url>
</webscript>

Javascript:

var connector = remote.connect("alfresco");
var data = connector.get("/upload/fileupload");//URL of Repository webscript     

// create json object from data
var result = eval('(' + data + ')');//This will parse json data
model.resultaat = result["resultaat"];//For adding data to model.

HTML.ftl result:

<#if resultaat??>
    ${resultaat}
<#else>
    Oh no, the folder name is empty!
</#if>

What I'm actually trying to do is call a Repo webscript that generates and put a report in the Repository. This works (see How to add a document to the Alfresco Repository with Java code?), but I want to call this from Share. So any suggestions?

EDIT: Updated the files.

1
  • did you found answer this use full? Commented Jul 3, 2015 at 12:41

1 Answer 1

2

Below is the code which you need to put in Share JS controller(webscript.get.js) for connecting to Repository webscript.

var connector = remote.connect("alfresco");
var data = connector.get("/sample/docprop.json");//URL of Repository webscript     

// create json object from data
var result = eval('(' + data + ')');//This will parse json data
model.docprop = result["docprop"];//For adding data to model.
Sign up to request clarification or add additional context in comments.

15 Comments

I get the following error: Cannot parse XML: Scanner State 24 not Recognized. It says it fails on line 5 of this example: customfileupload.get.js#5(eval)#1 Btw the data from my repo webscript is JSON, so I don't know why it's asking about XML.
If you see my comment , 3rd line is added for parsing json document and not xml.
It is JSON, I don't know why it says XML.
give me all files you can use pastebin
For the repo webscript files see the accepted answer of this Q: stackoverflow.com/questions/30304918/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.