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 first published in November 2001
This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

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

SearchVirtualDataCentre.co.UK

Close