Tuesday, March 10, 2009

Agent to Change Field Value in Lotus notes


To change the field value you have to always need to create some agent that will modify your database field. but in case if you are using multiple database and multiple changes then.... ????

So, now you can use this formula and create a toolbar button that will help you to change any of the field for any of the ... so enjoy..



choices := @DocFields;fullChoices := @Transform(choices; "x"; x + " = " +@Implode(@Text(@GetField(x)); ";"));fieldName := @Prompt([OkCancelEditCombo]; "Field Name"; "Select a fieldname from the dropdown listbox."; "";FullChoices);fieldName := @Left(fieldName; " = ");oldValue := @GetField(fieldname);newValue := @Explode(@Prompt([OkCancelEdit]; "New Field Value"; "Please enter the new field value." + @Char(13) +" Use ; for multivalues without mailto:space.@Implode(@Text(oldvalue);";")); ";");adjValue :=@If(@IsNumber(oldValue); @TextToNumber(newValue);@IsTime(oldValue); @TextToTime(newValue); newValue);@If(!@IsError(adjValue);@Do(@SetField(fieldName; adjValue); @Prompt([Ok]; "Field changed"; "Old field value: " + @Text(oldValue)+ @Char(13) + @Char(13) + "has been changed to" + @Char(13) + @Char(13) +"Nfield value: " + @Text(newValue)));@Prompt([YesNo]; "Change field value"; "New value not of same type as oldvalue. Set field to text?");@SetField(fieldName; newValue); "")