cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically associating XML with web form

ftoth
Champ in-the-making
Champ in-the-making
Hi all,

Is it possible to import XML into the system and associate it with a web
form after the fact?

For example, we want to import large chunks of meta-data into alfresco
from an external system. Once imported, we want to be able to edit
the meta-data with web forms.

We can create the imported XML to match the web form schema, but how
do we then create the association so that clicking "edit" works, bringing
up our XML in the appropriate form.

I trolled around in the node browser and I can see the various linkages,
but is there an easy way to create these?

Many thanks,

Fred
4 REPLIES 4

vijay_alfresco
Champ in-the-making
Champ in-the-making
I would suggest you to create a dummy data for all your webforms (give same names as that of your xml files) which generate you the .xml files with dummy data. Later you click update against this dummy data .xml file and select your actual xml file
and click on update.

Now, when you edit the updated .xml file you should see the webform with the new data.

Hope this helps and I think there is no directly way.

Thanks,
Vijay

marcus
Champ in-the-making
Champ in-the-making
You should be able to apply an (I think it's forminstancedata) then set one of the properties of that aspect to the noderef of the form that should be used to generate the content. You should be able to do this via javascript

tommorris
Champ in-the-making
Champ in-the-making
I have a scenario where I allow XML feeds to be dropped into an ADM space (a regular DM folder)
whereupon a script executes to re-write the XML so that it matches the schema of one of my web-forms.
I then associate it with that particular web-form and then copy it into the AVM,
ready for approval in one of the user's sandboxes. When they edit these items, they'll view it in the web-form editor.

The associating code snippet you're interested in is something like:

if (cleanedFile.isDocument && (cleanedFile.properties.content.encoding == "text/xml")) {
   var props = new Array(1);
   props["{http://www.alfresco.org/model/wcmappmodel/1.0}parentformname"] = form;
   cleanedFile.addAspect("{http://www.alfresco.org/model/wcmappmodel/1.0}forminstancedata", props);
}

The ".content.encoding" bit might be ".content.mimetype" on some alfresco versions.

Tom
http://www.ixxus.com

tamoracing
Champ in-the-making
Champ in-the-making
Thanks Tom, it worked!

I could associate programmatically an xml with an existing webform