SetFieldValue

Description

Places the specified value in the named field.

Si la zone peut être modifiée, cette méthode définit sa nouvelle valeur, valide ou non, et renvoie la chaîne vide. To determine whether a field contains a valid value, obtain the FieldInfo Object for that field and call the ValidityChangedThisSetValue method of the FieldInfo object to validate the field.

Si la zone ne peut être modifiée, la chaîne renvoyée en indique la raison. Les valeurs type incluent "no such field", "record is not being edited" et "field is read-only".

Si la zone peut avoir plusieurs valeurs, utilisez la méthode AddFieldValue pour ajouter chaque nouvelle valeur. It is still legal to use SetFieldValue; however, using SetFieldValue on a field that already contains a list of values replaces the entire list with the single new value.

Vous pouvez uniquement appeler cette méthode si l'objet Entity est éditable. Pour rendre un objet Entity existant éditable, appelez la méthode EditEntity de l'objet Session.

Remarque : After a hook changes a field property or value, you may need to refresh any local variables that correspond to the changed field or any other field. Setting a field value can cause hooks to fire which may change the value or requiredness of any field in the record. Hooks or scripts may need to refresh local variables to keep them current with the values in the record. Refresh local variables when current values are needed.

Syntaxe

VBScript

entity.SetFieldValue field_name, new_value 

Perl

$entity->SetFieldValue(field_name, new_value); 
Identificateur
Description
entity
Objet Entity représentant un enregistrement de données utilisateur. Si vous omettez cette partie de la syntaxe au sein d'un point d'ancrage, l'objet Entity correspondant à l'enregistrement de données en cours est faux (VBScript uniquement).
field_name
A String containing a valid field name of this Entity object.
nouvelle_valeur
For VBScript, a Variant containing the new value for the field. For Perl, a string containing the new value.
Return value
S'il est possible de modifier la zone, cette méthode renvoie une chaîne vide ; sinon, elle renvoie une chaîne contenant une explication de l'erreur.

Exemples

VBScript

' Set two field values, but only check errors for 
' the second field. 
entity.SetFieldValue "field1", "new value" 
returnVal = SetFieldValue("field2", "100") 

Perl

# Set two field values for the entity

# Perform error checking on the second field

$entity->SetFieldValue("field1","new value");

$returnval = $entity->SetFieldValue("field2","100"); 

Commentaires