Developer Function: Server Script: items.GetClosestSite
## Overview
This is the "GetClosestSite method" of the "[Items Object](/en/manual/server-script-items)". Use "「Site Name Search」" to get the site information closest to the site in question.
## Prerequisites
1. This function searches for the "Site name" of the site. Set the site name in advance. Note that this is not the "[Title](/en/manual/tenant-logo)" of the site.

## Syntax
```
items.GetClosestSite(name,id)
```
## Parameters
|Parameter|Type|Required|Description|
|:----------|:----------|:---:|:---------------------------|
|name|string|Yes|Specify the site name|
|id|int||Specify the search start site ID (default: site ID where the server script is stored)|
## Return Value
Returns the "「apiModel」" of the corresponding site.
If not found or you do not have access rights, null is returned.
## Usage Example
The following example retrieves site information for the site name "WBS".
```
const site = items.GetClosestSite('WBS');
if (site) {
context.Log(site.SiteId);
context.Log(site.Title);
context.Log(site.ReferenceType);
}
```
## Usage Example 1
The following example retrieves site information for the site name "WBS" from the site where the "[Server Script](/en/manual/table-management-server-script)" is stored.
```
const site = items.GetClosestSite('WBS');
```
## Usage Example 2
The following example retrieves site information for the site name "WBS" from the site with site ID 1234.
Use this in "[Background Server Script](/en/manual/background-server-script)".
```
const site = items.GetClosestSite('WBS',1234);
```
## Supplement
The difference between this and "[Developer Function: Server Script: items.GetSiteByName](/en/manual/server-script-items-get-site-by-name)" is that the items.GetSiteByName method returns all sites with the specified site name, but the item.GetClosestSite method returns the site with the specified site name closest to the search start site.
## Related Information
<div id="ManualList"><ul><li><a href="/en/manual/table-management-server-script">Table Management: Server Script</a><span>08.13.2024 up</span></li></ul></article>
<ul><li><a href="/en/manual/tenant-logo">Tenant Management Function: Logo, Title, Logo Image</a><span>10.08.2024 up</span></li>
<li><a href="/en/manual/background-server-script">Tenant Management Function: Background Server Script</a><span>08.13.2024 up</span></li></ul></article>
<ul><li><a href="/en/manual/server-script-items">Developer Function: Server Scripts: items</a><span>08.14.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />