cancel
Showing results for 
Search instead for 
Did you mean: 

Script url /updateSerialNum does not map to a Web Script.

sandile
Champ in-the-making
Champ in-the-making
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}

   
   
   






10 REPLIES 10

Hi,
the URL to be called should be: http://localhost:8080/alfresco/service/com/greenenergy/em/lab2/updateserialnum/22222/895b0032-90e5-4... using the nodeid since with the noderef notation you have problems with escaping.
Also, your files are in the form (just an example):
1)updateSerialNumber.get.desc.xml
2)updateSerialNumber.get.js
3)updateSerialNumber.get.html.ftl
and check if they are correctly installed under Alfresco using Alfresco service index.

Regards,
Andrea