how do we debug the bulk action javascript from ACCE?

1.1k views Asked by At

Can someone throw in their idea on how we can debug the javascript that we write from the bulk action script from ACCE? I understand that the alert or debug statement may not work there. What are the other options we have?

1

There are 1 answers

4
Christopher Powell On

What I do is write the script in java.

The imports are almost the same. Variables need to be redeclared as var instead of String etc. Everything else is pretty much the same.

Some things you might want to note: You might need to call refresh right away on ceobject. You will probably want to set up a java class with a method that brings in ceobject just like the JavaScript does.

IBM provides a JavaScript example of Setting document properties. There are other examples on the same page that demonstrate the use of Java api from within ACCE JavaScript.

This is a particularly good example as it shows one of the most common uses of the Bulk Update functionality:

importClass(Packages.com.filenet.api.property.Properties); 
importClass(Packages.com.filenet.api.constants.RefreshMode); 

function OnCustomProcess (CEObject) 
{ 
   CEObject.refresh(); 
   CEObject.getProperties().putValue("DocumentTitle", "Test1"); 
   CEObject.save(RefreshMode.REFRESH); 
} 

The exact same code written in Java:

import com.filenet.api.property.Properties;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.core.Document;

public class Java2JavaScript {

    public void OnCustomProcess (Document CEObject) 
    { 
       CEObject.refresh(); 
       CEObject.getProperties().putValue("DocumentTitle", "Test1"); 
       CEObject.save(RefreshMode.REFRESH); 
    }  

The following differences can be noted:

  1. import statement syntax is slightly different.
  2. The CEObject import is not needed for JavaScript, but is needed for Java. However it can be included in the JavaScript. In this case we import Document import com.filenet.api.core.Document; however other types of CEObject can be used instead of Document.
  3. Your Java class will need a valid class definition.
  4. You must declare CEObject in your Java method. Further, any declarations in java (i.e. String someString) need to change to a JavaScript declaration (var someString)
  5. Java "public void OnCustomProcess (Document CEObject)" simply becomes "function OnCustomProcess (CEObject)". ACCE will only accept "function OnCustomProcess (CEObject)" as the called function.