cancel
Showing results for 
Search instead for 
Did you mean: 

Problem passing data from share to alfresco

pavaniakella
Champ in-the-making
Champ in-the-making
Hi,

I created a webscript for searching the space in alfresco.
the following are the files I created

search.get.desc.xml
search.get.html.ftl – which contains a form three text boxes to enter search terms
search.post.desc.xml
search.post.html.ftl
search.post.js — this to process the fields  submitted and search the repository and return the results.In this I am using formdata.fields to retrieve the values from form fields.

The whole search function is working well.
Now I wanted to call this webscript from share.

I created the following files

propertysearch.get.desc.xml
propertysearch.get.html.ftl — contains form which was there in search.get.html.ftl
propertysearch.post.desc.xml
propertysearch.post.js — contains the following code.

var scriptURL= "/sample/search";
var connector = remote.connect("alfresco");
var postBody = {};
postBody.formdata =formdata;
var result = connector.post(scriptURL,jsonUtils.toJSONString(postBody), "application/json");
model.result = result;


I am not sure whether this is how we send the data because I am getting an error saying

Failed to execute script '/org/alfresco/sample/search.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 01090059 ReferenceError: "formdata" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/search.post.js#10)

org.mozilla.javascript.EcmaError - ReferenceError: "formdata" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/search.post.js#10)

org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)
org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)
org.mozilla.javascript.gen.c14._c0(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/search.post.js:10)
org.mozilla.javascript.gen.c14.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/search.post.js)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c14.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/search.post.js)
org.mozilla.javascript.gen.c14.exec(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/search.post.js)
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472)
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:190)
org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282)
org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:981)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:383)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
java.lang.Thread.run(Thread.java:619)

In the search.post.js I am retrieving the form fields data like this.

for each (field in formdata.fields)
{
  if (field.name == "ref")
  {
    ref= field.value;
  }
}



propertysearch.post.html.ftl

I am new to alfresco. Any Help is deeply appreciated.

Regards,
Pavani Akella
3 REPLIES 3

abhashree
Champ in-the-making
Champ in-the-making
Hi Pavaniakella,

Could you please post your codes of the search.post.js and search.post.html.ftl.

abarisone
Star Contributor
Star Contributor
Hi Pavaniakella,
could you also surround your code snippets with the
tag in order to enhance readability?

Thanks,
Andrea

jamil
Champ in-the-making
Champ in-the-making
Hi,

Please assist for the same post. I do have same issue.