Hi
I need help with a webscript. I am trying to update a serial number via the webscript.
Serial number is a property of a content type. The input to the web script will need to include the
noderef of the document that you wish to update, as well as the new serial number to update.
I am using the Alfresco webscript student guide, lab 2.
THE DESCRIPTOR FILE
<webscript>
<shortname>Update Serial Number</shortname>
<description>Update Serial Number of Equipment</description>
<family>Green Energy</family>
<url>/com/greenenergy/em/lab2/updateserialnum/{serialnum}/{noderef}/</url>
<format default="html" />
<authentication>user</authentication>
</webscript>
JAVA SCRIPT FILE
var serialnum = url.templateArgs["serialnum"];
//var noderef = url.templateArgs["noderef"];
var results = search.luceneSearch("@geem\:serialnum:\"'+serialnum+"\"");
// search for node by noderef
//var noderef="workspace://SpacesStore/85f170c7-26af-42d8-a913-6c8c6e8d51ff";
//var doc = search.findNode(noderef);
if(results!=null) {
// update the serial number property
doc.properties["geem:serialnum"]=serialnum;
doc.save();
model.message="Node (" + noderef + ") updated.";
}
else {
status.redirect=true;
status.code=500;
status.message="Document/node was not found!";
}
FTL FILE
${message}