Home > Domino Tips > Developer > Formula > Modifying document item values
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

FORMULA

Modifying document item values


Blessan V Philip
03.28.2006
Rating: -4.70- (out of 5) Hall of fame tip of the month winner


Lotus Notes and Domino tips, tutorials and how-to articles
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


VIEW MEMBER FEEDACK TO THIS TIP

This Formula Language code can be incorporated into a toolbar button for Lotus Notes client 6.5. When a database document is selected and the button is clicked, all item values will be displayed in a pop-up.

Follow these steps to change selected item values:

REM {Get a listing of all the fields 
on the current document}; 
List := @DocFields;
REM {Possible data types to 
choose from.};
DataTypes := "Text" : "Date" : 
"Integer" : "Password" : 
"Name" : "Common Name" :
 "Remove Field" : 
"Text Multi Value" : "Date Multi Value" :
 "Integer    Multi Value" 
: "Name Multi Value" : "Common Name 
Multi Value";
REM {Prompt for which field 
needs to be updated.}; 
EditField := @Prompt( [OkCancelList] ; 
"Select a field to alter" ; 
"Select the field you wish to alter:" ; 
"CustomerReply" ; List );
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 Picklist or any 
prompting needs to be used.};
DataType := @Prompt
( [OkCancelList] : [NoSort] ; 
"data type or action for field: " 
+ EditField ; 
"Please Select the correct data
 type or action for field: 
" + EditField ; "Text" ; DataTypes );
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 for field: " + EditField ; 
"Please enter the new desired value for: 
" + EditField + " seperated with : 
for each value." ; @Abstract([TextOnly] ; 254 ; 
"" ; @Text( EditField ) ) ); 
@Prompt( [OkCancelEdit] ; 
"New Value for field: " + EditField ; 
"Please enter the new desired value for: " 
+ EditField + "." ; @Abstract([TextOnly] ; 
254 ; "" ; @Text( EditField) ) ) );
REM {If data conversion 
doesn't work then don't set field.}; 
@If( DataType = "Date" ; 
@If( @SetField( EditField ; 
@TextToTime( RawValue ) ) ); 
DataType = "Integer" ; 
@If( @IsError( @TextToNumber
( RawValue ) ) ; "" ; 
@SetField( EditField ; 
@TextToNumber( RawValue ) ) ) ; 
DataType = "Common Name" ; 
@SetField( EditField ; 
@Name( [CN]; RawValue ) ) ; 
DataType = "Password" ; 
@SetField( EditField ; 
@Password( RawValue ) ) ; 
DataType = "Remove Field" ; 
@SetField( EditField ; @DeleteField ) ; 
DataType = "Text Multi Value" ; 
@SetField( EditField ; 
@Explode( RawValue ; ":" ) ) ; 
DataType = "Date Multi Value" ; 
@SetField( EditField ; 
@TextToTime( @Explode( RawValue ; ":" ) ) ) ; 
DataType = "Integer Multi Value" ; 
@If( @IsError
( @TextToNumber( @Explode
( RawValue ; ":" ) ) ) ; "" ; 
@SetField( EditField ; @TextToNumber
(@Explode( RawValue ; ":" ) ) ) ) ;
DataType = "Name Multi Value" ; 
@SetField( EditField ; 
@Explode( RawValue ; ":" ) ) ; 
DataType = "Common Name Multi Value" ; 
@SetField( EditField ; @Name( [CN]; 
@Explode( RawValue ; ":" ) ) ); 
@SetField( EditField ; RawValue ) ); ""

Do you have comments on this tip? Let us know.

MEMBER FEEDBACK TO THIS TIP

This tip is very similar to one submitted by Christiaan Walker, 3M Healthcare in March 2003. I've used his tip many times. The one big difference I've noticed is that it lets you know what is currently stored in the field.
—Bil M.

******************************************

This is a great tip, however, it does have a few bugs with multi-value:

  1. It shows current values with no separators. It should parse current values and add the colon separators. If I wanted to add one more value to the current value below, I would have to manually add in colons between each one before adding the new one to the end.
    [System] [Editors] [Admin] [CORP-Edit] [CORP-SS-Edit]

  2. It only stores as multi-value if you use colon to separate entries. It should allow for commas and semi-colons also, or have instructional text explaining to use colons.

—Julie B.

******************************************

To view the current values while changing; replace the existing code between the two remarks with the following code.

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];@GetField(EditField));
 @Contains( DataType ; "Name" ) ; 
@PickList( [Name] : [Single];@GetField
(EditField)); DataType = "Remove Field" ; "" ; 
@Contains( DataType ; "Multi Value" ); 
@Prompt( [OkCancelEdit] ; 
"New Value for field: " + EditField ; 
"Please enter the new desired value
for:  " + EditField + " seperated with : 
for each value." ; @Abstract([TextOnly] ; 254 ; "" ; 
@Implode(@Text( @GetField(EditField) );":") ) ); 
@Prompt( [OkCancelEdit] ; 
"New Value for field: " + EditField ; 
"Please enter the new desired value
for: "
+ EditField + "." ; @Abstract([TextOnly] ; 254 ;
 "" ; @Implode(@Text(
@GetField(EditField));":") ) ) );

REM {If data conversion doesn't 
work then don't set field.};

—Blessan Philip, tip author

Related information from SearchDomino.com:

  • Formula Language Learning Guide
  • Tip: Formula lookup for large domains
  • Reference Center: More Formula tips and resources

    This tip was submitted to the SearchDomino.com tip library by member Blessan Philip. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

    Rate this Tip
    To rate tips, you must be a member of SearchDomino.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


    RELATED CONTENT
    Formula
    Using Formula language code to sort Lotus Notes messages by subject
    How to create dynamic JavaScript in Notes Domino without formulas
    Formula language button manages Deny Access list searches
    Retrieve Lotus Notes names from a nested group using @DBLookup
    Create a computed Lotus Notes field to list Personal Address Book names
    Show multiple Lotus Notes document fields in a single view column
    How to send a document as a link in a Lotus Notes email
    How to generate formatted sequence numbers with Formula language
    A simpler pagination view for Lotus Notes documents on the Web
    A bevy of Notes/Domino development tips

    Lotus Notes Domino Formula Language
    Top 10 Formula language tips
    Using Formula language code to sort Lotus Notes messages by subject
    How to create dynamic JavaScript in Notes Domino without formulas
    Stop response documents from showing in a Lotus Notes form
    Formula language button manages Deny Access list searches
    Add a program doc to compact Lotus Notes databases automatically
    Top 10 Lotus Notes Domino programming and development tips of 2007
    Retrieve Lotus Notes names from a nested group using @DBLookup
    Top 5 @DBLookup tips
    Create a computed Lotus Notes field to list Personal Address Book names

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
    HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




    All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts