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

abarisone
Star Contributor
Star Contributor
Hi,
try to remove the leading/ from the webscript url:
/com/greenenergy/em/lab2/updateserialnum/{serialnum}/{noderef}

and check with <a>http://localhost:8080/alfresco/service/index</a> if it has been registered

Regards,
Andrea

sandile
Champ in-the-making
Champ in-the-making
Hi

I have removed it, I still get the same error.

yes it ix registered.

Regards

Hi,
could you please insert your complete file descriptor surrounded by code tags?
Is your webscript using POST or GET?
Could you provide the url you're trying to call from the browser?

Regards,
Andrea

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

the url trying to call in the browser http://localhost:8080/alfresco/service/22222/nodeRef=workspace://SpacesStore/895b0032-90e5-4672-949c...

am using the get method.
the noderef and serial number are of a content type.


serial number = 22222
noderef = workspace://SpacesStore/895b0032-90e5-4672-949c-c320891ede48

sandile
Champ in-the-making
Champ in-the-making
sorry here is a proper 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>

Hi,
try calling this url http://localhost:8080/alfresco/service/22222/workspace://SpacesStore/895b0032-90e5-4672-949c-c320891...
or, better try working with ids modifying your code
var node = findNodeById(url.templateArgs.id);
and calling the url omitting workspace://SpacesStore/

Regards,
Andrea

sandile
Champ in-the-making
Champ in-the-making
Hi

i have tried it. i still get the same error message.

Hi,
in order to help you, please provide all your files correctly formatted using blockcode tag and the exact url you call.
So we'll be able reproduce your exact condition…

Regards,
Andrea

sandile
Champ in-the-making
Champ in-the-making
Tha url I am trying to call is http://localhost:8080/alfresco/service/22222/workspace://SpacesStore/895b0032-90e5-4672-949c-c320891...

The 22222 represents the serial number of a content type with the noderef following after.




JAVASCRIPT FILE


var serialnum = url.templateArgs["serialnum"];

var noderef = url.templateArgs["noderef"];

var results = search.luceneSearch("@geem\:serialnum:\"'+serialnum+"\"");
var node = findNodeById(url.templateArgs.id);



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}



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>