Problem w/ View Action Agent

I am trying to create a simple, or so I thought, view action that does the following:

After the user selects one or more documents in a view they click the “Resign Territory” action button

Once the button is click a prompt appears, asking for the new salesperson # to be assigned to a the selected territory documents.

The action contains the following code:

@SetField(“newsls”;@Prompt([OkCancelList]; “New Salesperson”; “Select New Salesperson #:”; “”; @DbColumn(“”:“NoCache”; “”;“(Salesperson Lookup2)”; 1)));

@SetField(“newslsname”;@Right(@Trim(newsls);" "));

@SetField(“newslsnum”;@Left(@Trim(newsls);" "));

@Command([ToolsRunMacro];“(Reassign Territory)”)

The action calls an agent that is setup to run on all “selected documents”. The agent contains the following code:

@If(@Trim(newslsnum) != “” ;

@Do(

@SetField(“DBSLSM”;newslsnum);

@SetField(“DBSlsName”;newslsname);

@SetField(“newslsnum”;@DeleteField);

@SetField(“newslsname”;@DeleteField);

@SetField(“newsls”;@DeleteField);

@SetField(“newslsprompt”;@DeleteField)

);

@Failure(“Update Failed”));

SELECT Form =“Territory Maintenance”

The whole process only works when a single document is selected in the view.

If I choose multiple documents at once, the process does not work at all.

I’ve added prompts all over this thing to try and figure it. The only thing I am certain of is that the agent is getting run every time for each document that was selected in the view.

This is driving me nuts, what am I missing?

Thank you in advance.

Subject: Problem w/ View Action Agent (RESOLVED)

I figured out how to make this work. I needed to use 2 agents instead of one.

My view action button contains this code:

@Command([ToolsRunMacro];“(Change Salesperson Prompt)”)

My (Change Salesperson Prompt) agent contains this code (This agent is set as “Agent List Selection” Target = ‘None’):

newval := @Prompt([OkCancelList]; “New Salesperson”; “Select New Salesperson #:”; “”; @DbColumn(“”:“NoCache”; “”;“(Salesperson Lookup2)”; 1));

@SetEnvironment(“newsls”;newval);

@Command([ToolsRunMacro];“(Change Salesperson)”) ;

@All

My (Change Salesperson) agent contains this code(This agent is set as “Agent List Selection” Target = ‘Selected Documents’):

newslsm := @Trim(@Environment(“newsls”));

@If(newslsm = “” ;

@Return(@Prompt([Ok];“Error”;“no value in newsls.”)) ;

@Do(

@SetField(“DBSLSM”;@Left(@Trim(newslsm);4));

@SetField(“DBSlsName”;@Middle(@Trim(newslsm);5;25))

));

SELECT @All

I basically needed to use environment variables as well as putting the prompt for the new value in an agent.