Cycle through a list of agents gives an error

青春壹個敷衍的年華 提交于 2019-12-02 10:56:45

@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.

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...

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 ;)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!