Insert into Sub Element of Data Schema

Avatar

Avatar

michellec1024

Avatar

michellec1024

michellec1024

05-11-2019

Hi,

I am trying to insert data into an attribute that's under a sub element.

Here is the part of the script where I define what to insert:

  var event =

    <exampleEvent

      xtkschema = "exp:exampleEvent"

      _operation = "insert"

      deliveryTitle = {deliveryTitle}

    />

Here is an example of my data schema:

  <element name="exampleEvent">

    <element name="subExamples">

      <attribute label="Delivery Title" name="deliveryTitle" type="string"/>

    </element>

  </element>

If I were to take the 'deliveryTitle' attribute out of the subelement 'subExamples', then I am able to see data populate in the 'deliveryTitle' column. However, once I place the 'deliveryTitle' attribute into the sub element, data no longer populates.

Please advise.

Thanks,

Michelle

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Jyoti_Y

MVP

Avatar

Jyoti_Y

MVP

Jyoti_Y
MVP

05-11-2019

Hi,

Add data like you have defined your XML:

xtk.session.Write(

<exampleEvent  xtkschema = "exp:exampleEvent"    _operation = "insert">

< subExamples deliveryTitle = {deliveryTitle}/>

</exampleEvent> );

Thanks.

Answers (2)

Answers (2)

Avatar

Avatar

Jyoti_Y

MVP

Avatar

Jyoti_Y

MVP

Jyoti_Y
MVP

05-11-2019

Hi,

You should define it as:

  <exampleEvent

      xtkschema = "exp:exampleEvent"

      _operation = "insert"

      subExamples.deliveryTitle = {deliveryTitle}

    />

Your data will be saved in correct field.

Thanks.

Avatar

Avatar

michellec1024

Avatar

michellec1024

michellec1024

05-11-2019

Thanks for the reply. I’ve tried that and it didn’t work for me. The data did not show up in the field.

The data only shows up if I remove <element name=“subExamples”>....</element> from the data schema.