cancel
Showing results for 
Search instead for 
Did you mean: 

add nodes or delete nodes by web-script

ywxiong
Champ in-the-making
Champ in-the-making
How to add nodes or delete nodes by web-script ?
How to write this web-script?
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
Do you want to write a web script that adds or deletes nodes or use one of the existing web scripts to add or delete nodes?

ywxiong
Champ in-the-making
Champ in-the-making
both are great
would you provide me a demo with existing web-script first?
Thanks a lot

colindstephenso
Champ in-the-making
Champ in-the-making
A very simple script would be

var ppNode = search.xpathSearch("./app:company_home");
var parentName = ppNode[0].properties.name

var newfolder= ppNode[0].childByNamePath("newfolder");
if (newfolder == null)
{
    newfolder = ppNode[0].createFolder("newfolder");
}

var newfilenode = newfolder.createFile("newfile.txt");


OR a very simple example.

var newfolder = userhome.createFolder("newfolder");
var newfilenode = newfolder.createFile("newfile.txt");


The Alfresco Javascript API wiki is a great resource - http://wiki.alfresco.com/wiki/3.3_JavaScript_API

Cheers,

kizux
Champ in-the-making
Champ in-the-making
Hi, I allowed myself to post here because my question is similar :

I want to create a node that represents a link in an alfresco share's website, so the methode "createFile" doesn't seem appropriate.
Can you show me an example to create a node ? thanks for your help

duhannig
Champ in-the-making
Champ in-the-making
But how do you delete content

This shows how to upload a document

http://wiki.alfresco.com/wiki/Web_Scripts_Examples#File_Upload

But that example does not return any node information, if it did I could use:
#1 - DELETE /alfresco/service/api/node/{store_type}/{store_id}/{id}
This works but I have to manually look up the node reference {id}

But all I have is the file name and I cannot get
#2 - DELETE /alfresco/service/api/path/{store_type}/{store_id}/{nodepath}
to work. Is the {store_type} and {store_id} the same as #1 (ie workspace/SpaceStore) or is it something else
and is {nodepath} the file name?

A web script example on how to delete content by file name would be extremely helpful

Thanx