SaveAs method: FieldDefn class

Syntax

SaveAs(New_FieldName)

Description

Use this method to set the RuntimeDefn flag, validate, and save the field definition to the database.

Labels are copied from the source field to the target field. The translate values are copied if the field type is character (CHAR) and the field length is less than or equal to 4.

Parameters

Parameter Description

New_FieldName

Specifies the new name of the field.

Returns

An integer representing the following statuses.

Numeric Value Constant Value Description

0

%MDA_Success

The field definition is saved successfully.

1

%MDA_Failed

The field definition is not saved.

4

%MDA_Unsupported

The field type is not supported in PeopleCode.

5

%MDA_Duplicate

The given field already exists.

12

%MDA_InvalidDefn

This value is returned when the validation fails. The detailed validation error messages are available through the Messages property.

14

%MDA_NoWriteAccess

The user does not have write permissions to the field.

Example

Local FieldDefn &mktField = GetFieldDefn("MARKET");
If All(&mktField) Then
   &mktField.Description = "My new Market field";
   &retVal = &mktField.SetLabel("MYMARKET", "My Market", "My New Market", True);
   /* do error checking … */
   Local date &myDate = Date3(1900, 1, 1);
   &retVal = &mktField.SetTranslateValue("A", True, &myDate, "My New Market", "My Market");
   /* do error checking … */
   &retVal = &mktField.SaveAs("MYMARKET");
   /* do error checking … */
End-If;