cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a value from the url

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

I am trying to retrieve the noderef and serialnumber arguments from the url.
Every time i try to implement it gives me an error message "script url does not map to a webscript"

<DESCRIPTOR file>
<webscript>
   <shortname>Update Serial Number</shortname>
   <description>Update Serial Number of Equipment Proxy Document</description>
   <family>Green Energy</family>
   <url>/com/greenenergy/em/lab2/updateserialnum/{serialnum}/{noderef}</url>
   <format default="html"/>
   <authentication>user</authentication>
</webscript>




<SCRIPT CONTROLL file>

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

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


// search for node by noderef

var noderef="workspace://SpacesStore/85f170c7-26af-42d8-a913-6c8c6e8d51ff";
var doc = search.findNode(noderef);


if(doc!=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}
9 REPLIES 9

afaust
Legendary Innovator
Legendary Innovator
Hello,

what URL are you using to access your webscript?

Regards
Axel

abarisone
Star Contributor
Star Contributor
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
The url am trying to access the webscript is http://localhost:8080/alfresco/service/22222/workspace://SpacesStore/895b0032-90e5-4672-949c-c320891...

I have provided all the files in the first posted message.

Regards

mitpatoliya
Star Collaborator
Star Collaborator
There are two ways to pass parameter
the way you are passing parameter it going as part of url of webscript So you can access it as follow.

var fullpath=url.extension.split("/");
var serialnum=fullpath[0];

here url.extension is nothing but it will be your this part of URL
rest of the information you need to access through string operations
but you will face problem if you use .split because noderef contains "/"

22222/workspace://SpacesStore/895b0032-90e5-4672-949c-c320891ede48

Also It seems like URL which you are using is not proper.

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

please bear with me am a student learning alfresco.

Please enlighten me on the proper url to use.
What am trying to do is to use the serial number of the content type.

Am using the Alfresco training Web Scripts Student Guide version 2.1. am on lab 2  

mitpatoliya
Star Collaborator
Star Collaborator
You can go to this url
http://localhost:8080/alfresco/service/
then click on browser all url
then search for your script url in that list by name "Update Serial Number"
If it is registered properly it will be there
there you will have some url like "GET<REST OF THE URL>"
When you click on that link it will redirect you to the actual url of your script
all you need to do is replace the arguments with proper value.

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

ohk that was great progress at last.
Now the problem is i went to the url and put in the arguments but gave me an
ERROR 01120005 Web Script URI '/com/greenenergy/em/lab2/updateserialnum/22222/85f170c7-26af-42d8-a913-6c8c6e8d51ff' not found

mind you that this type exists.

mitpatoliya
Star Collaborator
Star Collaborator
It should be something like this
http://localhost:8080/alfresco/service/com/greenenergy/em/lab2/updateserialnum/22222/85f170c7-26af-4...
and if it is showing in the url list it means it is registered
any other error in log
post the screenshot of your browser with the url and result

sandile
Champ in-the-making
Champ in-the-making
URL: http://localhost:8080/alfresco/service/com/greenenergy/em/lab2/updateserialnum/22222/85f170c7-26af-4...

   Web Script Status 404 - Not Found

The Web Script /alfresco/service/com/greenenergy/em/lab2/updateserialnum/22222/85f170c7-26af-42d8-a913-6c8c6e8d51ff has responded with a status of 404 - Not Found.

404 Description:    Requested resource is not available.

Message:   01120007 Script url /com/greenenergy/em/lab2/updateserialnum/22222/85f170c7-26af-42d8-a913-6c8c6e8d51ff does not map to a Web Script.

Exception:   org.springframework.extensions.webscripts.WebScriptException - 01120007 Script url /com/greenenergy/em/lab2/updateserialnum/22222/85f170c7-26af-42d8-a913-6c8c6e8d51ff does not map to a Web Script.

org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:173)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:722)

Server:   Community v4.2.0 (4576) schema 6,022
Time:   Feb 12, 2013 2:03:48 PM



Sorry screenshot can't be posted, i copied the whole page.