Dumb question...but..selected documents not being changed

I want to do something I consider quite simple, but frustratingly can’t get it to work.I want a Picklist or Names.nsf dialogue to appear, the user selects the names, and all the selected documents are updated with the name they select. As the field will be emailed from and also for tidniness sake, I want the format of name giving the persons name and the abbreviate part of the CN=…

I have two agents, the first is here, runs on selection formula of ‘none’:-

FIELD DocumentOwner := DocumentOwner;

changeField := DocumentOwner;

tperson := @PickList([Name]:[Single]);

tperson1 := @Name([CN];tperson);

tperson2 := @Name([Canonicalize];tperson1 +“/”);

tperson3 := @Name([Abbreviate];tperson2);

newValue := tperson3;

@SetEnvironment(“changeField”;changeField);

@SetEnvironment(“newValue”;newValue);

@Command([ToolsRunMacro];“SetField”);

@All

So, we have displayed ONE picklist, the user has selected a name from it, we translate the name to a certain format, then set the @SetEnvironment values so we can use this value in the next agent, which runs on selected documents:-

FIELD DocumentOwner := DocumentOwner;

changeField := @Environment(“changeField”);

newValue := @Environment(“newValue”);

@SetField(changeField; newValue);

SELECT @All

The idea is then that all the documents are updated, the user is only displayed the one picklist.

The selection seems to be working. But the documents DO NOT get set to the new values…

Any ideas? Probably something quite small I’m missing, just need a reminder of whatever it is…

Thanks everyone.

Subject: Dumb question…but…selected documents not being changed…

Andrew,

I presume this line in your second agent:

@SetField(changeField; newValue);

is meant to change the value of the changeField field - in which case the field name needs to be in quotes - ie:

@SetField(“changeField”; newValue);

hth

Tony

Subject: RE: Dumb question…but…selected documents not being changed…

Tony,It doesnt need the qoutes because changefield is a temporary variable (set in the first agent).

Subject: RE: Dumb question…but…selected documents not being changed…

OK, I misread the code. You really confuse the issue by having variables with the same name as fields. However, if you’re going to use @SetField, then you need to be sure that the field exists. if it doesn’t then you need to put a ‘FIELD changeField := changeField’ line in there to initialise it before trying to set it.

hth

Tony

Subject: Actually that is no longer true. It has been fixed in R6.

Subject: Dumb question…but…selected documents not being changed…

Are you needing to do this with @Functions? You can do this with one agent, or script for that view itself, only asking for the information once, and updating all the records that were highlighted. Not a big fan of @functions here, so I wouldn’t be much help with the current set up.

Subject: I see an error…

FIELD DocumentOwner := DocumentOwner;changeField := DocumentOwner;

now changeField has the value of “” since your Target is None. Try:

tperson := @Name([Abbreviate]; @PickList([Name]:[Single]));

@SetEnvironment(“changeField”; “DocumentOwner”);

@SetEnvironment(“newValue”; tperson);

@Command([ToolsRunMacro];“SetField”);

@All

Your second Macro looks OK, but remove the first line:

changeField := @Environment(“changeField”);

newValue := @Environment(“newValue”);

@SetField(changeField; newValue);

SELECT @All

Subject: RE: I see an error…

Many thanks Bill. I have changed the code as you suggested and it works fine now. For prosperity’s sake, I’ll post the two agents below p.s. to the first poster - You can do it with one agent, but then the picklist appears three times instead of once - this way, you can interact with more than one document per agent run…

Heres the code:-

Agent One (runtime target - None)

tperson := @Name([Abbreviate]; @PickList([Name]:[Single]));

@SetEnvironment(“changeField”; “DocumentOwner”);

@SetEnvironment(“newValue”; tperson);

@Command([ToolsRunMacro];“SetField”);

@All

Agent Two (runtime target - selected documents)

changeField := @Environment(“changeField”);

newValue := @Environment(“newValue”);

@SetField(changeField; newValue);

SELECT @All