Sunday , December 17 2017
Home - Domino Migrations - Domino Lotus Notes – Edit Any Field

Domino Lotus Notes – Edit Any Field


There are times where field in a database needs to be changed without a Form.  This following code can be used in a smarticon on the toolbar to allow fields to edited or appended to a form.


In the following example – Select: File – Preferences – Toolbar – Customise.  Select ‘Universal’ as the toolbar to add the new button onto (this is shown regardless of Notes screen shown).   Select ‘New Button’.


Enter the ‘Button Caption Text’ as ‘EditAnyField’.  In the Formula screen copy and past the following script.



REM {Get a listing of all the fields on the current document};
List := @DocFields;

REM {Possible data types to choose from.};
REM {I called Number Integer because use keyboard to select what you want with keyboard quicker.};
DataTypes := “Text” : “Date” : “Integer” : “Password” : “Name” : “Common Name” : “**** Remove Field ****” : “Text Multi Value” : “Date Multi Value” : “Integer Multi Value” : “Name Multi Value”;

REM {Prompt for which field needs to be updated.};
EditField := @Prompt([OkCancelList]; “Select Field To Update”; “Select the field you wish to update:”; “”; List : “**** ADD A NEW FIELD ****”);

REM {If adding a new field, prompt for the field name};
NewFieldName := @If(EditField = “**** ADD A NEW FIELD ****”; @Prompt([OkCancelEdit]; “Enter Field Name”; “Enter the name of the new field:”; “”); “”);
CheckFieldName := @If(@IsMember(NewFieldName; List) & NewFieldName != “”; @Return(@Prompt([Ok]; “Already In List”; “The field ” + NewFieldName + ” already exists on the document.”)); “”);
UpdateVariable := @If(NewFieldName = “”; “”; EditField := NewFieldName);

REM {Prompt for which data type you would like the data to be};
REM {This needs to be done before value prompt to determine if the};
REM { Picklist or any prompting needs to be used.};
DataType := @Prompt([OkCancelList] : [NoSort]; “Choose Data Type”; “Please Select the correct data type or action for field: ” + EditField; “Text”; DataTypes);

REM {For multi-valued fields, let the user choose the separator to use};
Separator := @If(@Contains(DataType; “Multi Value”); @Prompt([OkCancelList] : [NoSort]; “Choose Separator”; “Choose the separator to split out your multiple values”; “:”; (“:” : “;” : “+” : “-” : “*”)); “”);

REM {Pull out the current value of the field};
CurrValue1 := @Eval(@Text(EditField));
CurrValue2 := @Abstract([TextOnly]; 254; “”; @Text(EditField));
CurrValue := @If(@IsNumber(CurrValue1) | @IsTime(CurrValue1); @Implode(@Text(CurrValue1); Separator); CurrValue2 != “”; CurrValue2; @Implode(@Text(CurrValue1); Separator));

REM {Based on what type of data is being entered different prompts will happen if any at all.};
RawValue := @If(
@Contains(DataType; “Name Multi Value”); @PickList([Name]);
@Contains(DataType; “Name”); @PickList([Name] : [Single]);
DataType = “**** Remove Field ****”; “”;
@Contains(DataType; “Multi Value”); @Prompt([OkCancelEdit]; “New Value”; “Please enter the new desired value for: ” + EditField + ” seperated with ” + Separator + ” for each value.”; CurrValue);
@Prompt([OkCancelEdit]; “New Value”; “Please enter the new desired value for: ” + EditField + “.”; CurrValue)

REM {If data conversion doesn’t work then don’t set field.};
DataType = “Date”; @If(@SetField(EditField; @TextToTime(RawValue)));
DataType = “Integer”; @If(@IsError(@TextToNumber(RawValue)); “”; @SetField(EditField; @TextToNumber(RawValue)));
DataType = “Password”; @SetField(EditField; @Password(RawValue));
DataType = “**** Remove Field ****”; @SetField(EditField; @DeleteField);
DataType = “Text Multi Value”; @SetField(EditField; @Explode(RawValue; Separator));
DataType = “Date Multi Value”; @SetField(EditField; @TextToTime(@Explode(RawValue; Separator)));
DataType = “Integer Multi Value”; @If(@IsError(@TextToNumber(@Explode(RawValue; Separator))); “”; @SetField(EditField; @TextToNumber(@Explode(RawValue; Separator))));
DataType = “Name Multi Value”; @SetField(EditField; @Explode(@Name([Canonicalize]; RawValue); Separator));
@SetField(EditField; RawValue)

Leave a Reply

Your email address will not be published. Required fields are marked *