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 n=0 ; n < agentList.length; ++n ){
4: var name:string = agentList[n];
5: dBar.info(name,"Agent Name ");
6: var ag:NotesAgent = database.getAgent(name);
7: dBar.info(ag.getName());
8: if (ag.isEnabled()){
9: dBar.info(ag.getName(),"Is Enabled ");
10: ag.isEnabled() = false;
11: }
12: }
The problem is that when I run it I get this error:
Error while executing JavaScript action expression Script interpreter error, line=6, col=38: [TypeError] Method NotesDatabase.getAgent(lotus.domino.local.Agent) not found, or illegal parameters
I know from the dBar that name is in fact the name of the first agent in the list and is a string. But it would appear that it is treating the name string as a lotus.domino.local.agent.
Am I missing something really obvious? I have Manager Access to the Database even set the max Internet access to Manager as well.
database.getAgents()
returns a list of agents, not a list of agent names. By coercingname
tostring
you might be able to convince the debug toolbar to tell you it is a string, but it shouldn't be.Try this:
Note in particular the substitution of
setEnabled()
in the last line of theif
...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.
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)):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):
Designer Help isn't all that bad, really ;)
@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.