Edit data without writing an agent

If you have a need to update data for a document and you always create an agent then this code is for you!

If you have a need to update data for a document and you always create an agent then this code is for you! All you need to do is paste this code into a SmartIcon.

There are five simple steps to using this code:
1) Select the document to update.
2) Click on the SmartIcon.
3) Select the field to update.
4) Select the data type or action to be performed
5) Enter a new .

Limitations:
1) Only perform the operation on one document at a time
2) Field value is limited to 254 because of the @Prompt limitations
3) Using Abstract for Multi value removes the multi value separator

The data types or actions are:
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 "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 )
);
""

This was last published in November 2001

Dig Deeper on J2EE for Lotus Notes Domino and WebSphere

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • 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 ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close