Problem solve Get help with specific problems with your technologies, process and projects.

How can documents be reordered using an agent?

I am looking for a way to reordered priority numbers -- specifically, a user selects a document with priority 6 and wants to change it to priority 3. How, through an agent, can you reordered all other documents on the view, so each has a unique and ordered priority value? The new priority value may be higher or lower than the current priority.
I'm not a big proponent of modifying multiple documents to change their order in a view, as it raises the likelihood of replication/save conflicts if there are multiple simultaneous users of the database or if there's a single user who likes to work on multiple documents simultaneously.

However, if you want to do it, assuming the priorities are already unique and sequential, the easiest way is probably to create a view action button with the following formula:

current_priority := Priority; REM {or whatever the fieldname is if not Priority};
priority_all := @DbColumn("":"NoCache"; ""; @Subset(@ViewTitle; -1); 1);
REM {above assumes the column with the priority number is number 1};
priority_choices := @Trim(@Replace(@Text(priority_all); @Text
(current_priority); ""));
new_priority := @Prompt([OkCancelList]; "Reprioritize"; "Select new priority 
for this document. NOTE: make sure none of these documents is open in another 
window."; ""; priority_choices);
ENVIRONMENT param1 := @Text(current_priority) + ":" + new_priority;
([ToolsRunMacro]; "(Adjust Priorities)")
Then create an agent named "(Adjust Priorities)" that runs on all documents in view. Here's the formula for that agent:

oldPri := @TextToNumber(@Left(@Environment("param1"); ":"));
newPri := @TextToNumber(@Right(@Environment("param1"); ":"));
min := @Min(oldPri; newPri);
max := @Max(oldPri; newPri);
SELECT Priority >= min & Priority <= max;
FIELD Priority :=
 @If(Priority = oldPri;
 Priority > oldPri;
 Priority - 1;
 Priority + 1

Dig Deeper on Lotus Notes Domino Agents

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...