> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NSForeignKey

> Carrier object for ForeignKey.

Carrier object for ForeignKey.

## Constructors

### NSForeignKey()

```crmscript theme={null}
NSForeignKey
```

Initializes a new instance of the NSForeignKey class.

## Methods

## GetCreatedBy()

```crmscript theme={null}
String GetCreatedBy()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Name of the person that created the foreign key.

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String createdBy = thing.GetCreatedBy();
```

## GetCreatedDate()

```crmscript theme={null}
DateTime GetCreatedDate()
```

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Registered when.

**Example:**

```crmscript theme={null}
NSForeignKey thing;
DateTime createdDate = thing.GetCreatedDate();
```

## GetKey()

```crmscript theme={null}
String GetKey()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Subkey (optional).

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String key = thing.GetKey();
```

## GetRecordId()

```crmscript theme={null}
Integer GetRecordId()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - Record in the referenced table.

**Example:**

```crmscript theme={null}
NSForeignKey thing;
Integer recordId = thing.GetRecordId();
```

## GetTableName()

```crmscript theme={null}
String GetTableName()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String tableName = thing.GetTableName();
```

## GetUpdatedBy()

Name of the person that last updated the foreign key

```crmscript theme={null}
String GetUpdatedBy()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Table name, transformed to and from numeric table id by the service layer.

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String updatedBy = thing.GetUpdatedBy();
```

## GetUpdatedDate()

```crmscript theme={null}
DateTime GetUpdatedDate()
```

**Returns:** [CRMScript.Global.DateTime](CRMScript.Global.DateTime) - Last updated when.

**Example:**

```crmscript theme={null}
NSForeignKey thing;
DateTime updatedDate = thing.GetUpdatedDate();
```

## GetValue()

```crmscript theme={null}
String GetValue()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - Key value.

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String value = thing.GetValue();
```

## SetCreatedBy(String)

```crmscript theme={null}
Void SetCreatedBy(String createdBy)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String createdBy;
thing.SetCreatedBy(createdBy);
```

## SetCreatedDate(DateTime)

```crmscript theme={null}
Void SetCreatedDate(DateTime createdDate)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
DateTime createdDate;
thing.SetCreatedDate(createdDate);
```

## SetKey(String)

```crmscript theme={null}
Void SetKey(String key)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String key;
thing.SetKey(key);
```

## SetRecordId(Integer)

```crmscript theme={null}
Void SetRecordId(Integer recordId)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
Integer recordId;
thing.SetRecordId(recordId);
```

## SetTableName(String)

```crmscript theme={null}
Void SetTableName(String tableName)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String tableName;
thing.SetTableName(tableName);
```

## SetUpdatedBy(String)

```crmscript theme={null}
Void SetUpdatedBy(String updatedBy)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String updatedBy;
thing.SetUpdatedBy(updatedBy);
```

## SetUpdatedDate(DateTime)

```crmscript theme={null}
Void SetUpdatedDate(DateTime updatedDate)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
DateTime updatedDate;
thing.SetUpdatedDate(updatedDate);
```

## SetValue(String)

```crmscript theme={null}
Void SetValue(String value)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSForeignKey thing;
String value;
thing.SetValue(value);
```


## Related topics

- [NSForeignSystemAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSForeignSystemAgent.md)
- [Foreign keys](/en/api/foreign-keys/index.md)
- [ForeignKeys](/en/api/archive-providers/reference/foreignkeys.md)
- [Delete Foreign Key](/en/api/reference/restful/agent/foreignsystem_agent/delete-foreign-key.md)
- [Save Foreign Key](/en/api/reference/restful/agent/foreignsystem_agent/save-foreign-key.md)
- [Add Foreign Key](/en/api/reference/restful/agent/foreignsystem_agent/add-foreign-key.md)
