Search code examples
javascriptxpagesagent

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


Solution

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