Returns the value of a string field.

HRESULT TryGetFieldString(
  LPCWSTR pcszFieldName,
  LPWSTR pszValue,
  ULONG * pcchValue);



[in, string] The name of the field.


[in, out, size_is(*pcchValue)] Returns the value of the specified field.


[in, out] Specifies the number of characters in pszValue. Returns the number of characters required to retrieve the specified field value when pszValue is too small; otherwise, returns the number of characters written, including the null terminator.

  • S_OK.

  • S_FALSE if the value has not been set or if it has been set to NULL.



  • SYNC_E_METADATA_FIELD_INVALID_NAME if the field does not exist.

  • SYNC_E_METADATA_FIELD_INVALID_TYPE if the field is not a string.

  • HRESULT_FROM_WIN32(ERROR_MORE_DATA) when pszValue is not large enough to receive the field value. In this situation, pcchValue returns the required number of characters.

Custom fields must be defined by using a CUSTOM_FIELD_DEFINITION structure when the replica metadata is first initialized.

If IItemMetadata::SetFieldString was called to set the field value, but the change has not yet been saved by a call to IReplicaMetadata::SaveItemMetadata, TryGetFieldString returns the value that is contained in the IItemMetadata object and not the value that is stored in the metadata store.

© 2016 Microsoft