Skip to content Skip to sidebar Skip to footer

Cycle Through A List Of Agents Gives An Error

I have this code on an action button that should just run through the Agents and disable all of the scheduled agents: var agentList:Array = database.getAgents(); 3: for (var

Solution 1:

database.getAgents() returns a list of agents, not a list of agent names. By coercing name to string you might be able to convince the debug toolbar to tell you it is a string, but it shouldn't be.

Try this:

var agentList = database.getAgents();
for (var n = 0; n < agentList.length; n++) {
    var eachAgent = agentList[n];
    if (eachAgent.isEnabled() {
        dBar.info(eachAgent.getName(), "Is Enabled");
        eachAgent.setEnabled(false);
    }
}

Note in particular the substitution of setEnabled() in the last line of the if...

Solution 2:

In LotusScript language Notesdatabase.Agents returns an array of NotesAgent objects.

I never tried in SSJS to day, but SSJS Domino Designer Help has this to say for the database.getAgents() method (see IBM Domino Designer XPages Reference > Domino > NotesDatabase (JavaScript)):

Syntax getAgents() : java.util.Vector

Usage The elements of the return vector are of type NotesAgent

and in the example that follows a java iterator is used to loop through the list of agent objects returned (looks exactly like your task, really):

var agents = database.getAgents().iterator();
var list = "";
while (agents.hasNext()) {
    list = list + agents.next().getName() + "\n";
}
return list

Designer Help isn't all that bad, really ;)

Solution 3:

@BillF: referring to your comments to @TimTripcony's answer:

a) LotusScript's language structure cannot be compared to what we have with SSJS: LS is a close relative to VisualBasic allowing read/write properties, whereas SSJS has a closer relationship to Java, where we usually have separate methods for reading and changing properties.

b) I think you are correct in doubting your approach of allowing the manipulation of a design element through http. A possible approach could be to write a server-side LS agent to perform your task which then could be triggered from your SSJS code. It might be necessary to use sessionAsSigner to be able to properly trigger the agent, and of course you need to make sure that only an Administrator may be able to do so.

Solution 4:

AS Tim wrote you need to setup that the ACL Maximum Internet name and password is set to at least Designer otherwise this will fail.

Internet maximum security level

Post a Comment for "Cycle Through A List Of Agents Gives An Error"