Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Insert into Sub Element of Data Schema

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

Add data like you have defined your XML:

xtk.session.Write(

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

< subExamples deliveryTitle = {deliveryTitle}/>

</exampleEvent> );

Thanks.

View solution in original post

3 Replies

Avatar

Community Advisor

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

Level 2

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.

Avatar

Correct answer by
Community Advisor

Hi,

Add data like you have defined your XML:

xtk.session.Write(

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

< subExamples deliveryTitle = {deliveryTitle}/>

</exampleEvent> );

Thanks.