Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:18:52+00:00 2026-06-03T13:18:52+00:00

I am working on the Event Handler for saving a component. My objective is

  • 0

I am working on the Event Handler for saving a component.

My objective is to perform some validations when the user creates and component based on a schema.

I have a schema with the name “Employee”.

Employee has an embedded schema with the name “Experience” and it is multivalued.

Experience has 3 fields.

  1. Role : Drop down with the values Manager, Lead.
  2. Company: Text field
  3. Years: Text field

When the user enters some data in these fields, I want to do some validations before save.

The high level design would look like this.

  1. Load the instance of the Component
  2. Navigate to embedded field “Experience”

For every “Experience”. I need to get the value of the “Role”, and check that appropriate value is entered in other two fields(By writing Component Save event)

For( all the repeated "Experience")
{
    If (Role=="Manager")
        check the values in the other two fields and do some validation
    If (Role=="Lead") 
        check the values in the other two fields and do some validation
}

I am stuck at extracting the value and Names of subfields at the embeddded field.

I have tried:

Tridion.ContentManager.Session mySession = sourcecomp.Session;
Schema schema= sourcecomp.Schema;
if(schema.Title.Equals("Employee"))
{
    var compFields = new ItemFields(sourcecomp.Content, sourcecomp.Schema);
    var embeddefield = (EmbeddedSchemaField)compFields["Experience"];

    var embeddedfields = (IList<EmbeddedSchemaField>)embeddefield.Values;
    foreach(var a in embeddedfields)
    {
        if(a.Name.Equals("Role"))
        {
            string value=a.Value.ToString();
        }
    }
}

Actually I am stuck how to retrieve the values in the other fields at the same time.

Can any one explain how it can be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:18:54+00:00Added an answer on June 3, 2026 at 1:18 pm

    What you need to understand on a EmbeddedSchemaField class is that it represents both a schema and a field (as the name implies…)

    I always find it helpful to look at the source XML of the component when writing code that targets its fields, you get a good visual representation of what your classes must do. If you look at a component XML like this:

    <Content>
        <Title>Some Title</Title>
        <Body>
                <ParagraphTitle>Title 1</ParagraphTitle>        
                <ParagraphContent>Some Content</ParagraphContent>
        </Body>
        <Body>
                <ParagraphTitle>Title 2</ParagraphTitle>        
                <ParagraphContent>Some more Content</ParagraphContent>
        </Body>
    </Content>        
    

    Body is your embedded Schema field, which is multivalued, and contains 2 single-valued fields within it.

    Addressing these fields in TOM.NET then:

    // The Component
    Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
    // The collection of fields in this component
    ItemFields content = new ItemFields(c.Content, c.Schema);
    // The Title field:
    TextField contentTitle = (TextField)content["Title"];
    // contentTitle.Value = "Some Title"
    // Get the Embedded Schema Field "Body"
    EmbeddedSchemaField body = (EmbeddedSchemaField)content["Body"];
    // body.Value is NOT a field, it's a collection of fields.
    // Since this happens to be a multi-valued field, we'll use body.Values
    foreach(ItemFields bodyFields in body.Values)
    {
        SingleLineTextField bodyParagraphTitle = (SingleLineTextField)bodyFields["ParagraphTitle"];
        XhtmlField bodyParagraphContent = (XhtmlField) bodyFields["ParagraphContent"];
    }
    

    Hope this gets you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Google Map working on my site. There is an event handler
I am working on a network application with threading. I have an event handler
I'm working on a .NET Windows Forms application. I have an event handler procedure
I'm working on an EventRegistry that lets register some event handlers. Every time an
I've been working with some event handling in Javascript and recently decided to migrate
I am working on triggering an event to create a page automatically, when user
I'm working on a game with a event based structure with the main game
I have a remote javascript file containing a custom jQuery event handler. When this
In my Adobe Air application I have a change event handler attached to a
I'm working on a project with some event handling code. Basically, I create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.