cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript alert ERROR

chicco0386
Champ on-the-rise
Champ on-the-rise
Hi,
i've this javascript file and it is into the companyHome->DataDictionary->Scripts for run into a Rules:

// Retrieve the last DocID value from the counter at the Space level
if (parseInt(space.properties["custom:numP"]) == null)
   LastDocID=0;
else
   LastDocID = parseInt(space.properties["custom:numP"]);
// Generate new DocID value
NewDocID = LastDocID + 1;

// Store the new value in the space
space.properties["custom:numP"] = NewDocID;
space.save();

// Store the DocID in the document's metadata
document.properties["custom:numeroP"] = NewDocID;
document.save();
alert("Doc saved");

After create the rules that run the script "Execute javascript" i've see this message:
The rules have been successfully reapplied.
A system error happened during the operation: Transaction didn't commit: Failed to execute script 'workspace://SpacesStore/f4777eb8-fd9c-4591-b9b1-6b2c88109bfe': ReferenceError: "alert" is not defined. (AlfrescoScript#16)

CAN YOU HELP ME?
THANKS
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
Your JavaScript is running via Rhino on the server - it's not client-side JavaScript! Therefore you don't have web browser ("DOM") extensions like: window, document, location and alert.

Mike

chicco0386
Champ on-the-rise
Champ on-the-rise
Your JavaScript is running via Rhino on the server - it's not client-side JavaScript! Therefore you don't have web browser ("DOM") extensions like: window, document, location and alert.

Mike

THANKS.
But can I solved this in some mode?

mikeh
Star Contributor
Star Contributor
If you mean how can you debug your webscripts, then you can use the following:
if (logger.isLoggingEnabled())
{
   logger.log("Doc saved");
}
and then update the log4j entry:
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug

Thanks,
Mike

chicco0386
Champ on-the-rise
Champ on-the-rise
If you mean how can you debug your webscripts, then you can use the following:
if (logger.isLoggingEnabled())
{
   logger.log("Doc saved");
}
and then update the log4j entry:
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug

Thanks,
Mike


OK..THANKS
I've understand that the alert of javascript can't be used in alfresco javascript….