[This is preliminary documentation and is subject to change.]
Namespace: ContentStudio.EventActions
Assembly: CS5Interfaces (in CS5Interfaces.dll) Version: 1.0.0.0 (1.0.0.0)
The ICSEptContent type exposes the following members.
Name | Description | |
---|---|---|
Count |
Gets the number of fields in this ICSEptContent
implementation.
| |
Fields |
Gets an ICollectionT containing the
fields of this ICSEptContent implementation.
| |
Item |
Gets or sets the value of a field with the specified name.
|
Name | Description | |
---|---|---|
AddField |
Adds a new field to the current ICSEptContent
implementation.
| |
ContainsField |
Determines whether the name represents an existing field.
| |
GetEnumerator | (Inherited from IEnumerableICSEptField.) | |
RemoveField |
Removes a field from the current ICSEptContent
implementation.
| |
TryGetValue |
Gets the value of the specified field.
| |
TrySetValue |
Sets the value of the specified field.
|
Note |
---|
This interface was added in Content Studio version 5.3 |
The possibility of changing document content that is about to be saved in the OnBeforeDocumentSave event opens up a number of possibilities for the programmer. For example you could combine two or more EPT-fields into another field to create a new view of the data. Before Content Studio 5.3 you had to do these kinds of operations on the client using javascript code.
The following code shows an handler that combine data from two EPT fields, FirstName and LastName, into a third field, DisplayName. The field DisplayName must exist in the schema or it will be ignored by Content Studio
//Only works in an handler that handles the OnBeforeDocumentSave event public class MyBeforeDocumentSaveHandler : BeforeDocumentSaveSyncHandler { protected override void DoWork() { if (DocumentStatus.IsEptDocument) { EptContent["DisplayName"] = String.Format("{0} {1}", EptContent["FirstName"], EptContent["LastName"]); } } }
Note |
---|
The following is new in Content Studio 5.5 |
A special case is when there are more than one field with the same name. This is not recommended but allowed. In this case all the fields sharing the same name will be combined into one single multi valued field where each field value is separated by the MultiFieldValueSeparator separator. The following code shows how to handle multi valued fields.
//Only works in an handler that handles the OnBeforeDocumentSave event //Content Studio 5.5 and later only public class MyBeforeDocumentSaveHandler : BeforeDocumentSaveSyncHandler { protected override void DoWork() { if (DocumentType == DocumentTypes.EPT_Document) { if (EptContent.ContainsField("FullName") && EptContent.ContainsField("FirstName") && EptContent.ContainsField("LastName")) { var firstNames = EptContent["FirstName"].Split(new[] { EventAction.MultiFieldValueSeparator }, StringSplitOptions.None); var fullName = String.Join(" ", firstNames); EptContent["FullName"] = String.Concat(fullName, " ", EptContent["LastName"]); } } } }