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
BedrockMission!

Learn More

View all

Sign in to view all badges

Auto-increment custom primary key

Avatar

Avatar
Validate 1
Level 1
bharathn7761115
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bharathn7761115
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bharathn7761115
Level 1

27-01-2019

I have a requirement to create a schema with a custom primary key with auto-increment functionality.

I have created  the below schema.

<element autopk="false" desc="Terms and Conditions Table" label="Terms And Conditions"

           labelSingular="Terms And Conditions" name="terms_conditions" pkSequence="auto_custerms_conditions_sequence">

    <attribute autoIncrement="true" label="Terms Key" name="terms_key" type="long"/>

    <attribute label="Terms" name="terms" type="string"/>

    <attribute label="Terms Start Date" name="terms_start_date" type="datetime"/>

    <key internal="true" name="terms_key">

      <keyfield xpath="@terms_key"/>

    </key>

  </element>

Note that I have specified autoIncrement="true" in terms_key attribute definition.

But after inserting records, the "terms_key" is not getting auto-incremented.  Is defining schema with autopk=true and leveraging campaign generated id field is the only option?

Thanks

Bharath

View Entire Topic

Avatar

Avatar
Validate 1
Level 1
bharathn7761115
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bharathn7761115
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bharathn7761115
Level 1

28-01-2019

Thanks for your quick response. That worked.

The other workaround I tried is to delete the entire schema and recreate it. That also worked. Looks like autoIncrement=true only works if we add it while creating the scheme.

- Bharath