Insert into Sub Element of Data Schema

Avatar

Avatar
Validate 1
Level 1
michellec1024
Level 1

Likes

3 likes

Total Posts

9 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back
Ignite 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
michellec1024
Level 1

Likes

3 likes

Total Posts

9 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back
Ignite 1
Boost 3
Boost 1
View profile
michellec1024
Level 1

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

Replies

Avatar

Avatar
Boost 50
MVP
Jyoti_Y
MVP

Likes

88 likes

Total Posts

123 posts

Correct reply

55 solutions
Top badges earned
Boost 50
Shape 1
Boost 5
Give Back 5
Give Back 3
View profile

Avatar
Boost 50
MVP
Jyoti_Y
MVP

Likes

88 likes

Total Posts

123 posts

Correct reply

55 solutions
Top badges earned
Boost 50
Shape 1
Boost 5
Give Back 5
Give Back 3
View profile
Jyoti_Y
MVP

05-11-2019

Hi,

Hi,

Add data like you have defined your XML:

xtk.session.Write(

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

< subExamples deliveryTitle = {deliveryTitle}/>

</exampleEvent> );

Your data will be saved in correct field.

Thanks.

Avatar

Avatar
Validate 1
Level 1
michellec1024
Level 1

Likes

3 likes

Total Posts

9 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back
Ignite 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
michellec1024
Level 1

Likes

3 likes

Total Posts

9 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back
Ignite 1
Boost 3
Boost 1
View profile
michellec1024
Level 1

06-11-2019

Thanks jyotiy - I tried your solution above and got this error:

JST-310000 Error while compiling script 'exp:exampleEvent.js' line 51: invalid XML name (line=' < subExamples deliveryTitle = {deliveryTitle}/>\n' token=' subExamples deliveryTitle = {deliveryTitle}/>\n').

Avatar

Avatar
Boost 50
MVP
Jyoti_Y
MVP

Likes

88 likes

Total Posts

123 posts

Correct reply

55 solutions
Top badges earned
Boost 50
Shape 1
Boost 5
Give Back 5
Give Back 3
View profile

Avatar
Boost 50
MVP
Jyoti_Y
MVP

Likes

88 likes

Total Posts

123 posts

Correct reply

55 solutions
Top badges earned
Boost 50
Shape 1
Boost 5
Give Back 5
Give Back 3
View profile
Jyoti_Y
MVP

06-11-2019

Hi,

Can you share your script you have written.

Is your subelement name correctly defined? Also have you defined deliveryTitle variable.

In order to analyse what is wrong you need to share table structure and script you have written.

Code which I have provided is correct.

Thanks.