# pk, parentpk()

## pk() or pk("tablename")

### parentpk()

pk() - return the primary key of the current table or nominated table as a string.

parentpk() -returns the Primary Key of the parent of the current table.

## Arguments

Argument | Data Type | Description
table name or alias (optional) | string | The name of the table to return the primary key for. If not specified, the current table is used. An alias may be used if there is more than one instance of the same table - set up the alias in the Pre/Post Operation tab on the target table.

## Returns

The primary key of the current table or the named table. parentpk() is used to return the primary key of the parent of the current table.

## Description

The purpose of these functions are to give you access to the primary key of a record that has just been modified by Inaport. You should not use it in the 'Add Fields' or 'Change Data' tabs, because at this point Inaport has not touched records.

You can use it in the 'Match and Map' tab, in either:

- the source expression for a field mapping, or
- the pre- and post expressions.

A typical use might be to get the primary key of a parent table, and use it to update a field in a target table.

## Examples

In these examples, suppose we have the following set of tables:

> account

> > contact

> > > customContact

Example | Returns
pk() (on the customContact table) | Primary key of the record just created/updated on customContact
pk("contact") (on the customContact table) | Primary key of the record just matched/created/updated on the parent contact table
pk("account") (on the customContact table) | Primary key of the record just matched/created/updated on the grandparent account table

## See Also

Pre and Post Expressions , isnomatch(), issinglematch(), ismultiplematch(), matchresult()