Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!
SOLVED

why we neeed to define autopk=true in data schema in ACC

Avatar

Level 3

HI ALL

why we need to define autopk=true in data schema in ACC

 

WHAT WILL HAppEN IF WE DONT define AUTOPK=true in  data schema 

if we seT BELOW CODE IT WILL DECLARE PRIAMRY KEY

THEN AUTOPK=true in  data schema will it also declare primary key?just confused with the difference in these two

@AkshayAnand 

@Craig_Thonis 

@Manoj_Kumar_ 

@Amine_Abedour 

@Marcel_Szimonisz

@DavidKangni 

@Amit_Kumar 

@ShashankNigam02

@Ganesh5067

@Jonathon_wodnicki

 

key name="PrimaryKey" internal="true">
  <keyfield xpath="@name"/>
</key>

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@jefrii ,

Schema requires an unique attribute for each data row (records), which is primary key.

If you feel you don't have a dedicated attribute as a primary key in your schema, and to insert a record define autopk="true" . This will create a attribute "id" and auto-sequence for it. So whenever a new record gets inserted, the Primary key (@id) will keeps on incrementing which will be unique.

If your schema have dedicated attribute as primary key, you don't have to use autopk and can use the primary key definition syntax as you mentioned in question part.

<key name="PrimaryKey" internal="true">
  <keyfield xpath="@name"/>
</key>

 In this case, if you try to insert 2 records with same "name" it will throw an error stating 'duplicate in primary key'

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@jefrii ,

Schema requires an unique attribute for each data row (records), which is primary key.

If you feel you don't have a dedicated attribute as a primary key in your schema, and to insert a record define autopk="true" . This will create a attribute "id" and auto-sequence for it. So whenever a new record gets inserted, the Primary key (@id) will keeps on incrementing which will be unique.

If your schema have dedicated attribute as primary key, you don't have to use autopk and can use the primary key definition syntax as you mentioned in question part.

<key name="PrimaryKey" internal="true">
  <keyfield xpath="@name"/>
</key>

 In this case, if you try to insert 2 records with same "name" it will throw an error stating 'duplicate in primary key'

Avatar

Community Advisor

Hi @jefrii ,

 

The attribute autopk="true" is defined in the element tag of the Schema only if we require the auto incremental Primary Key sequence like 1,2,3 and so on..

 

Example : We can consider nms:recipient OOTB schema, which has autopk="true" in the schema tag, the below column and the Primary key syntax comes up in the Preview Tab even though it was not added manually in the Edit Tab of the Schema. Below is the Sample Code which gets automatically added in the Preview Tab if autopk is defined,

 

 

<attribute desc="Internal primary key" label="Primary key" name="id" sqlname="iRecipientId"
type="long"/>

<key internal="true" name="id">
<keyfield xpath="@id"/>
</key>

 

It is mandatory to define the Primary Key for any Schema in Adobe Campaign but It is not mandatory to define autopk="true" in the Schema(autopk is used as per our requirements only), If the Uniqueness is based on an attribute or combination of attributes then the Primary key should be defined on them.

 

Example: In Schema called cus:product , the 2 columns product_id and product_name are having uniqueness, then we need to define the Primary Key in edit Tab of our Schema as below:

 

<key internal="true" name="PK_product">
<keyfield xpath="@product_id"/>

<keyfield xpath="@product_name"/>
</key>

 

PFA Documentation Links for reference

 

https://experienceleague.adobe.com/docs/campaign-classic/using/configuring-campaign-classic/schema-r...

 

Regards,

Pravallika.