cancel
Showing results for 
Search instead for 
Did you mean: 

javascript prompt

xerox
Champ in-the-making
Champ in-the-making
I'm trying to do an alert or promp in alfresco with javascript, but this isn't working.
Isn't this possible in Alfresco?

friendly regards,
Nick
14 REPLIES 14

mikeh
Star Contributor
Star Contributor
Hi,

There shouldn't be any reason why not - you're not trying to put one in a server-side script, are you?

Mike

xerox
Champ in-the-making
Champ in-the-making
no,just a javascript in the webclient.

simple prompt code:

var name=prompt("sometext","defaultvalue");


the error:
org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing: Failed to execute script 'workspace://SpacesStore/1118dbd7-464d-11dc-884d-adf88105aace': ReferenceError: "prompt" is not defined. (AlfrescoScript#1)
caused by:
org.alfresco.service.cmr.repository.ScriptException: Failed to execute script 'workspace://SpacesStore/1118dbd7-464d-11dc-884d-adf88105aace': ReferenceError: "prompt" is not defined. (AlfrescoScript#1)
caused by:
org.alfresco.error.AlfrescoRuntimeException: ReferenceError: "prompt" is not defined. (AlfrescoScript#1)
caused by:
org.mozilla.javascript.EcmaError: ReferenceError: "prompt" is not defined. (AlfrescoScript#1)

friendly regards

Nick
(using alfresco 1.4 enterprise)

mikeh
Star Contributor
Star Contributor
Ah, but that must be running on the server-side to throw that exception.

You can only prompt the user with client-side javascript, i.e. running in the browser via a <script> tag in the rendered HTML, not the Javascript API engine running on the server.


Mike

xerox
Champ in-the-making
Champ in-the-making
thanx… now it doesn't give an error anymore,but I still don't see the prompt.

freemarker link:


<a href="/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts//createproject.js&contextPath=/Company%20Home/Intranet/file.txt" ><h2>Create new project</h2></a>


javascript code:


var name= "<script>prompt(\"sometext\",\"defaultvalue\");</script>";
name;
var myfolder = space.createFolder("Planning");
var myfolder = space.createFolder("Reporting");
var myfolder = space.createFolder("TA");
var goback = "<script>history.back();</script>";
goback;


It just creates the folders but doesn't show the prompt

mikeh
Star Contributor
Star Contributor
Hi,

You have to prompt the user on the client before invoking the createproject.js script, something like this:

<script type="text/javascript">
   function createNewProject(url)
   {
      var name = prompt("Type the name here", "defaultValue");
      location.href = url + "&name=" + name;
   }
</script>

<a href="#" onclick="createNewProject('/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts//createproject.js&contextPath=/Company%20Home/Intranet/file.txt'); return false;">
   <h2>Create new project</h2>
</a>

Then you pull out the submitted name variable on the server and use that when creating your space.

Thanks,
Mike

xerox
Champ in-the-making
Champ in-the-making
thanks for your support…

It's working now

mikeh
Star Contributor
Star Contributor
No problem - glad I could help.

Mike

xerox
Champ in-the-making
Champ in-the-making
another questionSmiley Happy



I've created a link(in freemarker) when users click on it, it makes some folders. Now I want to hide that link for users that don't have write acces in that folder. Is ist possible in alfresco 1.4?


Maybe I can  sent the permissions back from the serverjavascript to the client javascript? or isn't this possible?

xerox
Champ in-the-making
Champ in-the-making
*bump*