cancel
Showing results for 
Search instead for 
Did you mean: 

Web script returning form instances?

morf3usz
Champ in-the-making
Champ in-the-making
Hi,

I have following question. I'm totally fresh with alfresco web scripts. I have read a piece of tutorials, however I'm not smarter with my problem. Can someone show me, how shall look a webscript, that returns all instances of concrete WebForm? Let's suppose, we have a WebForm called MovieItem, and we have several instances of this form. The script should return all nodes, that are the instances of this form.

Best Regards
Morf3usz
6 REPLIES 6

invictus9
Champ in-the-making
Champ in-the-making
The first thing you need to know is how do you identify web forms of type "Movie Item". Are they kept as a content type? An aspect on a standard cm:content?

You might want to look at

http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Find_all_XML_Forms_of_a_Specific_Type_and_Retu...

morf3usz
Champ in-the-making
Champ in-the-making
Hi,

Yes, the form are kept as "content". No aspects on them, just simple XML data. The name of the form is MovieItem. Here is the code of the form:


<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:hbbtv="http://hbbtv.mds.com" elementFormDefault="qualified" targetNamespace="http://hbbtv.mds.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="MovieItem">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Id" type="xs:long" />
            <xs:element name="Title" type="xs:normalizedString" />
            <xs:element name="Description" type="xs:string" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>
The target is to obtain all instances of the form, to display their content in an another webscript.

Regards
Morf3usz

invictus9
Champ in-the-making
Champ in-the-making
What I was hinting is that you need some form of tagging or associations to search effectively.

If you add an aspect that allows the search engine to find "all documents with aspect my:movieitem", you could find things quickly.

morf3usz
Champ in-the-making
Champ in-the-making
invictus9, thanks for answer. However, could you give some example, how to attach an aspect to the web forms instance? I can't find any reasonable sample. The forms wizard does not have option "add aspect to a form", I also can't see such option while editing the form.

Regards
Morf3usz

morf3usz
Champ in-the-making
Champ in-the-making
Sorry for answering to my own post, but I found the option "Run Action —> Add aspect". This ables to add an aspect to the web form. I attached aspect titled "Someco Webable" with name "sc:webable". Now, when I write in the webscript:

var results = search.luceneSearch("ASPECT\\:Someco Webable");
or

var results = search.luceneSearch("ASPECT:\\sc:webable");
the resultset is always "undefined" What am I doin wrong?

Regards
Morf3usz

larryp7639
Champ in-the-making
Champ in-the-making
The first thing you need to know is how do you identify web forms of type "Movie Item". Are they kept as a content type? An aspect on a standard cm:content?

You might want to look at

http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Find_all_XML_Forms_of_a_Specific_Type_and_Retu...

Such a very amazing link!
Thanks you for the post.