속성 서비스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Properties 서비스를 사용하면 부가기능이 사용되는 하나의 스크립트, 스크립트의 한 사용자 또는 하나의 문서에 범위가 지정된 키-값 쌍에 간단한 데이터를 저장할 수 있습니다. 일반적으로 개발자 구성이나 사용자 환경설정을 저장하는 데 사용됩니다. 속성은 스크립트 간에 공유되지 않습니다.
속성 서비스의 일일 할당량 및 스토리지 한도를 보려면 Google 서비스 할당량을 참고하세요.
속성 스토어 비교
PropertiesService
전역 객체는 세 가지 메서드를 제공하며, 각 메서드는 다음 표와 같이 유사한 Properties
객체를 반환하지만 액세스 권한이 다릅니다.
Properties 서비스는 모든 데이터를 키-값 쌍으로 문자열로 저장합니다. 이미 문자열이 아닌 데이터 유형은 저장된 객체 내에 포함된 메서드를 비롯하여 자동으로 문자열로 변환됩니다.
데이터 저장
단일 값을 저장하려면 다음 예와 같이 적절한 저장소의 Properties.setProperty(key,
value)
메서드를 호출합니다.
데이터를 일괄적으로 저장하려면 키-값 쌍의 맵을 Properties.setProperties(properties)
에 전달하세요.
파라미터에 있는 객체의 각 키-값 쌍은 별도의 속성으로 저장됩니다.
데이터 읽기
이전에 저장한 단일 값을 검색하려면 Properties.getProperty(key)
를 호출합니다.
현재 속성 저장소의 모든 값을 가져오려면 Properties.getProperties()
를 호출하세요.
데이터 수정
getProperty()
및 getProperties()
메서드는 저장된 데이터의 사본을 반환하며 라이브 뷰를 반환하지 않으므로 반환된 객체를 변경해도 속성 저장소의 값이 업데이트되지 않습니다. 스토어의 데이터를 업데이트하려면 다시 저장하면 됩니다.
데이터 삭제
단일 값을 삭제하려면 Properties.deleteProperty(key)
를 호출합니다.
현재 저장소의 모든 속성을 삭제하려면 Properties.deleteAllProperties()
을 호출하세요.
스크립트 속성을 수동으로 관리하기
프로젝트 설정 페이지에서 키-값 쌍의 문자열로 최대 50개의 맞춤 속성을 수동으로 추가할 수 있습니다. 50개가 넘는 속성을 추가하려면 데이터 저장에 설명된 방법을 사용하여 프로그래밍 방식으로 추가해야 합니다.
프로젝트 설정 페이지에서 스크립트 속성을 설정할 때는 스크립트 변수를 참조할 수 없습니다.
스크립트 속성 추가
- Apps Script 프로젝트를 엽니다.
- 왼쪽에서 프로젝트 설정
을 클릭합니다.
- 첫 번째 속성을 추가하려면 스크립트 속성에서 스크립트 속성 추가를 클릭합니다.
- 두 번째 이후 속성을 추가하려면 스크립트 속성에서 스크립트 속성 수정 > 스크립트 속성 추가를 클릭합니다.
- 속성에 키 이름을 입력합니다.
- 값에 키 값을 입력합니다.
- (선택사항) 속성을 더 추가하려면 스크립트 속성 추가를 클릭합니다.
- 스크립트 속성 저장을 클릭합니다.
스크립트 속성 수정
- Apps Script 프로젝트를 엽니다.
- 왼쪽에서 프로젝트 설정
을 클릭합니다.
- 스크립트 속성에서 스크립트 속성 수정을 클릭합니다.
- 변경하려는 각 속성의 키 이름과 키 값을 변경합니다.
- 스크립트 속성 저장을 클릭합니다.
스크립트 속성 삭제
- Apps Script 프로젝트를 엽니다.
- 왼쪽에서 프로젝트 설정
을 클릭합니다.
- 스크립트 속성에서 스크립트 속성 수정을 클릭합니다.
- 삭제하려는 속성 옆에 있는 삭제 close를 클릭합니다.
- 스크립트 속성 저장을 클릭합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThe Properties service allows you to store simple data as key-value pairs, with separate stores for script, user, and document properties.\u003c/p\u003e\n"],["\u003cp\u003eData is stored as strings and automatically converted if it's a different data type, with access varying depending on the chosen property store.\u003c/p\u003e\n"],["\u003cp\u003eYou can save, read, modify, and delete data within these property stores using specific methods provided by the Properties service.\u003c/p\u003e\n"],["\u003cp\u003eScript properties can also be managed manually through the project settings page for a limited number of custom properties.\u003c/p\u003e\n"]]],[],null,["# Properties Service\n\nThe [Properties service](/apps-script/reference/properties) lets you store\nsimple data in key-value pairs scoped to one script, one user of a script, or\none document in which an [add-on](/workspace/add-ons/overview) is used. It is\ntypically used to store developer configuration or user preferences. Properties\nare never shared between scripts.\n\nTo view the daily quotas and storage limits for the Properties service, see\n[Quotas for Google Services](/apps-script/guides/services/quotas).\n\nComparison of property stores\n-----------------------------\n\nThe\n[`PropertiesService`](/apps-script/reference/properties/properties-service)\nglobal object offers three methods, each of which returns a similar\n[`Properties`](/apps-script/reference/properties/properties)\nobject but with different access rights, as shown in the following table:\n\n| | Script Properties | User Properties | Document Properties |\n|--------------------|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| Method to access | [getScriptProperties()](/apps-script/reference/properties/properties-service#getScriptProperties()) | [getUserProperties()](/apps-script/reference/properties/properties-service#getUserProperties()) | [getDocumentProperties()](/apps-script/reference/properties/properties-service#getDocumentProperties()) |\n| Data shared among | All users of a script, add-on, or web app | The current user of a script, add-on, or web app | All users of an add-on in the open document |\n| Typically used for | App-wide configuration data, like the username and password for the developer's external database | User-specific settings, like metric or imperial units | Document-specific data, like the source URL for an embedded chart |\n\nData format\n-----------\n\nThe Properties service stores all data as strings in key-value pairs. Data types\nthat are not already strings are automatically converted to strings, including\nmethods contained within saved objects.\n\nSaving data\n-----------\n\nTo save a single value, call the method [`Properties.setProperty(key,\nvalue)`](/apps-script/reference/properties/properties#setProperty(String,String))\nof the appropriate store, as shown in the following example: \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Set a property in each of the three property stores.\n const scriptProperties = PropertiesService.getScriptProperties();\n const userProperties = PropertiesService.getUserProperties();\n const documentProperties = PropertiesService.getDocumentProperties();\n\n scriptProperties.setProperty('SERVER_URL', 'http://www.example.com/');\n userProperties.setProperty('DISPLAY_UNITS', 'metric');\n documentProperties.setProperty('SOURCE_DATA_ID',\n '1j3GgabZvXUF177W0Zs_2v--H6SPCQb4pmZ6HsTZYT5k');\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nTo save data in bulk, pass a map of key-value pairs to\n[`Properties.setProperties(properties)`](/apps-script/reference/properties/properties#setProperties(Object)).\nEach key-value pair of the object in the parameter is stored as a separate\nproperty: \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Set multiple script properties in one call.\n const scriptProperties = PropertiesService.getScriptProperties();\n scriptProperties.setProperties({\n 'cow': 'moo',\n 'sheep': 'baa',\n 'chicken': 'cluck'\n });\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nReading data\n------------\n\nTo retrieve a single value that you have previously saved, call\n[`Properties.getProperty(key)`](/apps-script/reference/properties/properties#getProperty(String)): \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Get the value for the user property 'DISPLAY_UNITS'.\n const userProperties = PropertiesService.getUserProperties();\n const units = userProperties.getProperty('DISPLAY_UNITS');\n console.log('values of units %s', units);\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nTo retrieve all values in the current property store, call\n[`Properties.getProperties()`](/apps-script/reference/properties/properties#getProperties()): \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Get multiple script properties in one call, then log them all.\n const scriptProperties = PropertiesService.getScriptProperties();\n const data = scriptProperties.getProperties();\n for (const key in data) {\n console.log('Key: %s, Value: %s', key, data[key]);\n }\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nModifying data\n--------------\n\nThe methods `getProperty()` and `getProperties()` return a copy of the stored\ndata, not a live view, so changing the returned object will not update the value\nin the property store. To update the data in the store, simply save it again: \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Change the unit type in the user property 'DISPLAY_UNITS'.\n const userProperties = PropertiesService.getUserProperties();\n let units = userProperties.getProperty('DISPLAY_UNITS');\n units = 'imperial'; // Only changes local value, not stored value.\n userProperties.setProperty('DISPLAY_UNITS', units); // Updates stored value.\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nDeleting data\n-------------\n\nTo delete a single value, call\n[`Properties.deleteProperty(key)`](/apps-script/reference/properties/properties#deleteProperty(String)): \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Delete the user property 'DISPLAY_UNITS'.\n const userProperties = PropertiesService.getUserProperties();\n userProperties.deleteProperty('DISPLAY_UNITS');\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nTo delete all properties in the current store, call\n[`Properties.deleteAllProperties()`](/apps-script/reference/properties/properties#deleteAllProperties()): \nservice/propertyService.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/service/propertyService.gs) \n\n```javascript\ntry {\n // Get user properties in the current script.\n const userProperties = PropertiesService.getUserProperties();\n // Delete all user properties in the current script.\n userProperties.deleteAllProperties();\n} catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed with error %s', err.message);\n}\n```\n\nManage script properties manually\n---------------------------------\n\nYou can manually add up to fifty custom properties, as strings in key-value\npairs, from the project settings page. To add more than fifty properties, you\nneed to add them programmatically using the methods described above in\n[Saving data](#saving-data).\nWhen you set script properties from the project settings page, you can't\nreference script variables.\n\n### Add script properties\n\n1. Open your Apps Script project.\n2. At the left, click **Project Settings** .\n3. To add the first property, under **Script Properties** click **Add script property**.\n4. To add second and subsequent properties, under **Script Properties** click **Edit script properties** \\\u003e **Add script property**.\n5. For **Property**, enter the key name.\n6. For **Value**, enter the value for the key.\n7. (Optional) To add more properties, click **Add script property**.\n8. Click **Save script properties**.\n\n### Edit script properties\n\n1. Open your Apps Script project.\n2. At the left, click **Project Settings** .\n3. Under **Script Properties** , click **Edit script properties**.\n4. Make changes to the key name and key value for each property you want to change.\n5. Click **Save script properties**.\n\n### Delete script properties\n\n1. Open your Apps Script project.\n2. At the left, click **Project Settings** .\n3. Under **Script Properties** , click **Edit script properties**.\n4. Next to the property that you want to delete, click Remove close.\n5. Click **Save script properties**."]]