---
sourceDocument: 호주 API 참조
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/api-reference

 Release :

    - australia

ft:locale :

    - ko-KR

ft:publication_title :

    - 호주 API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideSysAttachment - 범위 지정됨

# GlideSysAttachment - 범위 지정됨 {#ariaid-title1}

* 릴리스 버전: Australia
* 
* 업데이트 날짜 2026년 03월 12일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 28분

GlideSysAttachment API는 첨부 파일을 처리하는 메서드를 제공합니다.

getContent()가 호출될 때 컨텐츠는 바이트 배열이 아닌 문자열로 반환됩니다.

getContentStream()이 호출되면 컨텐츠가 GlideScriptableInputStream 객체로 반환됩니다. GlideScriptableInputStream에는 문자열로 변환되지 않은 실제 바이트가 포함되어 있습니다.

## 범위가 지정된 GlideSysAttachment - GlideSysAttachment() {#ariaid-title2}

GlideSysAttachment 클래스의 인스턴스를 만듭니다.
{#r_SGSA-GlideSysAttachment__table_iys_ctb_fv__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 안 함 |   |   |
[표 1. 매개변수]

{#r_SGSA-GlideSysAttachment__table_iys_ctb_fv}

## 범위가 지정된 GlideSysAttachment - addAttribute(String sysAttachmentID, String attrKey, String attrValue) {#ariaid-title3}

기존 첨부 파일 기록에 단일 속성을 추가합니다.
참조 :

* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-addAttribute_S_S_S__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - addAttribute(문자열 attrKey, 문자열 attrValue)](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-addAttribute_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
{#SGSA-addAttribute_S_S_S__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
| 속성 키 | 문자열 | 첨부 파일 속성에 대한 키-값 쌍의 키 부분입니다. |
| 속성 값 | 문자열 | 첨부 파일 속성에 대한 키-값 쌍의 값 부분입니다. |
[표 2. 매개변수]

{#SGSA-addAttribute_S_S_S__table_rql_3mg_5fc} {#SGSA-addAttribute_S_S_S__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| 없음 |   |
[표 3. 반환]

{#SGSA-addAttribute_S_S_S__table_sql_3mg_5fc}  
다음 예제에서는 <kbd class="ph userinput">author</kbd> 키와 <kbd class="ph userinput">Fred Luddy</kbd> 값을 사용하여 지정된 첨부 파일에 특성을 추가하는 방법을 보여 줍니다. 결과는 첨부 파일 속성 \[sys_attachment_attribute\] 테이블에서 볼 수 있습니다.

    var attach = new GlideSysAttachment();
    attach.addAttribute("9e1b714601932210f877b455304df0af", "author", "Fred Luddy");

    var result = attach.fetchAttribute("9e1b714601932210f877b455304df0af", "author");

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + " \nValue: " + result.getValue('value')); 
    }

출력:

    Key: author 
    Value: Fred Luddy

## 범위가 지정된 GlideSysAttachment - addMultipleAttributes(String, sysAttachmentID, Object, attrsKeyValuePair) {#ariaid-title4}

첨부 파일 기록에 여러 속성을 추가합니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-addMultipleAttributes_S_O__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - addMultipleAttributes(객체 attrsKeyValuePair)](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-addMultipleAttributes_O "첨부 파일 기록에 여러 속성을 추가합니다.")
{#SGSA-addMultipleAttributes_S_O__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
| attrs키값쌍 | 객체 | 키-값 쌍 집합의 첨부 파일 속성입니다. 각 속성 키와 해당 값은 문자열로 제공되어야 합니다. 예: var attachmentAttributes = { "description" : "Photo of the solar system", "dimensions" : "1600 x 300" } |
[표 4. 매개변수]

{#SGSA-addMultipleAttributes_S_O__table_rql_3mg_5fc} {#SGSA-addMultipleAttributes_S_O__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| 없음 |   |
[표 5. 반환]

{#SGSA-addMultipleAttributes_S_O__table_sql_3mg_5fc}  
다음 예제에서는 지정된 첨부 파일에 특성을 추가하는 방법을 보여 줍니다. 첨부 파일 속성 \[sys_attachment_attribute\] 테이블에서도 결과를 확인할 수 있습니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    var attrsKeyValuePair = { };
      attrsKeyValuePair["title"]  = "Add multiple attributes to an attachment";
      attrsKeyValuePair["category"] =  "KB";
      attrsKeyValuePair["length"] =  "5000";

    attach.addMultipleAttributes(attachmentID, attrsKeyValuePair);

    var result = attach.fetchAllAttributes(attachmentID);

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + ", Value: " + result.getValue('value'));
    }

출력:

    Key: title, Value: Add multiple attributes to an attachment
    Key: author, Value: Abel Tuter
    Key: category, Value: KB
    Key: length, Value: 5000

## 범위가 지정된 GlideSysAttachment - copy(String sourceTable, String sourceID, String targetTable, String targetID) {#ariaid-title5}

소스 기록에서 대상 기록으로 첨부 파일을 복사합니다.
주:  
첨부 파일을 복사하면 첨부 파일에 할당된 속성도 복사됩니다. 첨부 파일 속성 \[sys_attachment_list\] 테이블에서 할당된 속성 목록을 보거나 fetchAllAttributes() 메서드를 실행할 수 있습니다.
{#r_SGSA-copy_S_S_S_S__id_kdj_vjz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sourceTable | 문자열 | 복사할 첨부 파일이 있는 테이블의 이름입니다. |
| 소스 ID | 문자열 | 소스 테이블의 sys_id입니다. |
| targetTable | 문자열 | 첨부 파일을 추가할 테이블의 이름입니다. |
| 대상 ID | 문자열 | 첨부 파일을 복사할 대상 테이블의 기록 sys_id입니다. |
[표 6. 매개변수]

{#r_SGSA-copy_S_S_S_S__id_kdj_vjz_g5b} {#r_SGSA-copy_S_S_S_S__id_db3_wjz_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 복사된 첨부 파일 sys_ids의 배열입니다. 테이블: 첨부 파일 \[sys_attachment\] |
[표 7. 반환]

{#r_SGSA-copy_S_S_S_S__id_db3_wjz_g5b}  
이 예는 인시던트 기록에서 문제 기록으로 첨부 파일을 복사하는 방법을 보여줍니다.

    var attachment = new GlideSysAttachment();
    var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
    var incGR = new GlideRecord('incident');
    incGR.get(incidentSysID);

    var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id'));
    gs.info('Copied attachments: ' + copiedAttachments);

출력:

    Copied attachments: 6e4621df1bc420501363ff37dc4bcbb0,a87769531b0820501363ff37dc4bcba2

## 범위가 지정된 GlideSysAttachment - deleteAllAttributes(String, sysAttachmentID) {#ariaid-title6}

기존 첨부 파일 기록에서 모든 속성을 삭제합니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-deleteAllAttributes_S__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-deleteAllAttributes "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
{#SGSA-deleteAllAttributes_S__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
[표 8. 매개변수]

{#SGSA-deleteAllAttributes_S__table_rql_3mg_5fc} {#SGSA-deleteAllAttributes_S__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| 부울 | 속성이 성공적으로 삭제되었는지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다. * true: 속성이 성공적으로 삭제되었습니다. * false: 속성이 성공적으로 삭제되지 않았습니다. {#SGSA-deleteAllAttributes_S__ul_kwy_cth_5fc} |
[표 9. 반환]

{#SGSA-deleteAllAttributes_S__table_sql_3mg_5fc}  
다음 예제에서는 지정된 첨부 파일에 할당된 모든 속성을 삭제하는 방법을 보여 줍니다. 첨부 파일 속성 \[sys_attachment_attribute\] 테이블에서도 결과를 확인할 수 있습니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    attach.deleteAllAttributes(attachmentID);

    var result = attach.fetchAllAttributes(attachmentID);

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + ", Value: " + result.getValue('value')); 
    }

출력:

    Attribute "null" not found for attachment "04f48541083e2e50f877df7a115e31f3"

## 범위가 지정된 GlideSysAttachment - deleteAttachment(문자열 attachmentID) {#ariaid-title7}

지정된 첨부 파일을 삭제합니다.
주:  
첨부 파일을 삭제하면 할당된 속성도 삭제됩니다. 첨부 파일 속성 \[sys_attachment\] 테이블에서 할당된 속성 목록을 보거나 fetchAllAttributes() 메서드를 실행할 수 있습니다.
{#r_SGSA-deleteAttachment_S__id_ajy_dlz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 첨부 파일 ID | 문자열 | 첨부 파일의 sys_id입니다. 테이블: 첨부 파일 \[sys_attachment\] |
[표 10. 매개변수]

{#r_SGSA-deleteAttachment_S__id_ajy_dlz_g5b} {#r_SGSA-deleteAttachment_S__table_gjy_lyb_fv__entry__2}

| 유형 | 설명 |
|-|-|
| 무효 |   |
[표 11. 반환]

{#r_SGSA-deleteAttachment_S__table_gjy_lyb_fv}  

    var attachment = new GlideSysAttachment();
    var attachmentSysID = 'a87769531b0820501363ff37dc4bcba2';
    attachment.deleteAttachment(attachmentSysID);

## 범위가 지정된 GlideSysAttachment - deleteAttribute(String, sysAttachmentID, String, attrKey) {#ariaid-title8}

첨부 파일 기록에서 지정된 속성을 삭제합니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-deleteAttribute_S_S__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - deleteAttribute(문자열 attrKey)](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-deleteAttribute_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
{#SGSA-deleteAttribute_S_S__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
| 속성 키 | 문자열 | 첨부 파일 속성에 대한 키-값 쌍의 키 부분입니다. |
[표 12. 매개변수]

{#SGSA-deleteAttribute_S_S__table_rql_3mg_5fc} {#SGSA-deleteAttribute_S_S__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| 부울 | 첨부 파일 속성이 성공적으로 삭제되었는지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다. * true: 첨부 파일 속성이 성공적으로 삭제되었습니다. * false: 첨부 파일 속성이 성공적으로 삭제되지 않았습니다. {#SGSA-deleteAttribute_S_S__ul_val_cth_5fc} |
[표 13. 반환]

{#SGSA-deleteAttribute_S_S__table_sql_3mg_5fc}  
다음 예제에서는 <kbd class="ph userinput">author</kbd> 키를 사용하여 지정된 첨부 파일에 할당된 속성을 삭제하는 방법을 보여 줍니다. 첨부 파일 속성 \[sys_attachment_attribute\] 테이블에서도 결과를 확인할 수 있습니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    attach.deleteAttribute(attachmentID, "author");

    var result = attach.fetchAttribute(attachmentID, "author");

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + " \nValue: " + result.getValue('value')); 
    }

출력:

    Attribute "author" not found for attachment "04f48541083e2e50f877df7a115e31f3"

## 범위가 지정된 GlideSysAttachment - fetchAllAttributes(String, sysAttachmentID) {#ariaid-title9}

지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-fetchAllAttributes_S__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-fetchAllAttributes "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
{#SGSA-fetchAllAttributes_S__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
[표 14. 매개변수]

{#SGSA-fetchAllAttributes_S__table_rql_3mg_5fc} {#SGSA-fetchAllAttributes_S__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| [GlideRecord](https://servicenow-prod.fluidtopics.net/PdjBDkljzRHVS4qRn2BIdw#c_GlideRecordScopedAPI "범위가 지정된 GlideRecord API는 데이터베이스 작업에 사용됩니다.") | 첨부 파일 기록과 모든 속성입니다. |
[표 15. 반환]

{#SGSA-fetchAllAttributes_S__table_sql_3mg_5fc}  
다음 예제에서는 지정된 첨부 파일에 할당된 모든 속성을 가져오는 방법을 보여 줍니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    var result = attach.fetchAllAttributes(attachmentID);

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + ", Value: " + result.getValue('value')); 
    }

출력:

    Key: title, Value: Add multiple attributes to an attachment
    Key: author, Value: Abel Tuter
    Key: category, Value: KB
    Key: length, Value: 5000

## 범위가 지정된 GlideSysAttachment - fetchAttribute(String, sysAttachmentID, String, attrKey) {#ariaid-title10}

첨부 파일 기록에서 지정된 속성을 가져옵니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-fetchAttribute_S_S__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - fetchAttribute(문자열 attrKey)](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-fetchAttribute "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
{#SGSA-fetchAttribute_S_S__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
| 속성 키 | 문자열 | 첨부 파일 속성에 대한 키-값 쌍의 키 부분입니다. |
[표 16. 매개변수]

{#SGSA-fetchAttribute_S_S__table_rql_3mg_5fc} {#SGSA-fetchAttribute_S_S__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| [GlideRecord](https://servicenow-prod.fluidtopics.net/PdjBDkljzRHVS4qRn2BIdw#c_GlideRecordScopedAPI "범위가 지정된 GlideRecord API는 데이터베이스 작업에 사용됩니다.") | 첨부 파일 및 지정된 속성의 GlideRecord입니다. |
[표 17. 반환]

{#SGSA-fetchAttribute_S_S__table_sql_3mg_5fc}  
다음 예제에서는 <kbd class="ph userinput">author</kbd> 키를 사용하여 첨부 파일 속성을 가져오는 방법을 보여 줍니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    var result = attach.fetchAttribute(attachmentID, "author");

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + " \nValue: " + result.getValue('value')); 
    }

출력:

    Key: author 
    Value: Abel Tuter

## 범위가 지정된 GlideSysAttachment - getAttachments(문자열, tableName, 문자열 sys_id) {#ariaid-title11}

이름, 유형 또는 크기 등 일치하는 첨부 파일 메타데이터를 포함하는 GlideRecord를 반환합니다.
{#r_SGSA-getAttachments_S_S__id_bvk_jmz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| tableName | 문자열 | 첨부 파일이 속한 테이블의 이름입니다. 예: 인시던트. |
| sys_id | 문자열 | 첨부 파일이 속한 기록의 Sys_id입니다. |
[표 18. 매개변수]

{#r_SGSA-getAttachments_S_S__id_bvk_jmz_g5b} {#r_SGSA-getAttachments_S_S__id_urm_kmz_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| GlideRecord | 이름, 유형 또는 크기와 같은 일치하는 첨부 파일 메타데이터를 포함하는 GlideRecord 객체입니다. |
[표 19. 반환]

{#r_SGSA-getAttachments_S_S__id_urm_kmz_g5b}  
다음 스크립트는 첨부 파일이 두 개인 기록의 첨부 파일 이름을 나열합니다.

    var attachment = new GlideSysAttachment();

    var agr = attachment.getAttachments('<table_name>', '<record_sys_id>');

    while(agr.next())
    gs.info(agr.getValue('file_name'));

출력:

    *** Script: filename1.txt
    *** Script: filename2.txt

## 범위가 지정된 GlideSysAttachment - getContent(GlideRecord sysAttachment) {#ariaid-title12}

첨부 파일 콘텐츠를 문자열로 반환합니다.
이 방법은 범위가 지정된 애플리케이션에서만 사용됩니다. 이 메서드는 전역 범위에서 사용되는 경우 `정의되지 않음` 을 반환합니다. 전역 범위에서 첨부 파일 컨텐츠를 읽으려면 GlideSysAttachment - 전역 API에서 getContentStream() 메서드를 사용합니다.  
이 방법은 첨부 파일에 대해 다음 파일 형식을 지원합니다.

* CSV(\*.csv)
* JSON(\*.json)
* 텍스트(\*.txt)
{#r_SGSA-getContent_GR__ul_zd2_w21_cwb}
{#r_SGSA-getContent_GR__table_r2d_cng_2v__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 시스템 첨부 파일 | GlideRecord | 첨부 파일 기록입니다. |
[표 20. 매개변수]

{#r_SGSA-getContent_GR__table_r2d_cng_2v} {#r_SGSA-getContent_GR__table_s2d_cng_2v__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 첨부 파일 내용을 문자열로 표시합니다. 최대 5MB의 데이터를 반환합니다. |
[표 21. 반환]

{#r_SGSA-getContent_GR__table_s2d_cng_2v}  

    var attachment = new GlideSysAttachment();

    var agr = attachment.getAttachments('incident', '78271e1347c12200e0ef563dbb9a7109'); //create attachment GlideRecord

    while(agr.next()) { //for each attachment on the incident record
       gs.info(agr.getValue('file_name')); //print file name of attachment
       var attachmentContent = attachment.getContent(agr);
       gs.info('Attachment content: ' + attachmentContent); //print attachment content
    }

출력:

    Doc1.txt
    Attachment content: I am text in a txt file attached to a record.

## 범위가 지정된 GlideSysAttachment - getContentBase64(GlideRecord sysAttachment) {#ariaid-title13}

첨부 파일 콘텐츠를 base64 인코딩의 문자열로 반환합니다.
이 방법은 범위가 지정된 애플리케이션에서만 사용됩니다. 이 메서드는 전역 범위에서 사용되는 경우 `정의되지 않음` 을 반환합니다. 전역 범위에서 첨부 파일 콘텐츠를 읽으려면 GlideSysAttachment - 전역 API의 getContentStream 메서드를 사용합니다.
{#r_SGSA-getContentBase64_GR__table_kds_4sb_fv__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 시스템 첨부 파일 | GlideRecord | 첨부 파일 기록입니다. |
[표 22. 매개변수]

{#r_SGSA-getContentBase64_GR__table_kds_4sb_fv} {#r_SGSA-getContentBase64_GR__table_lds_4sb_fv__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | base64 인코딩을 사용하는 문자열로 표시되는 첨부 파일 콘텐츠입니다. 최대 5MB의 데이터를 반환합니다. |
[표 23. 반환]

{#r_SGSA-getContentBase64_GR__table_lds_4sb_fv}  

    var attachment = new GlideSysAttachment();

    var agr = attachment.getAttachments('incident', '78271e1347c12200e0ef563dbb9a7109'); //create attachment GlideRecord

    while(agr.next()) { //for each attachment on the incident record
       gs.info(agr.getValue('file_name')); //print file name of attachment
       var attachmentContent = attachment.getContentBase64(agr);
       gs.info('Attachment content: ' + attachmentContent); //print attachment content
    }

출력:

    Doc1.txt
    Attachment content: SSBhbSB0ZXh0IGluIGEgdHh0IGZpbGUgYXR0YWNoZWQgdG8gYSByZWNvcmQuIA0=

## 범위가 지정된 GlideSysAttachment - getContentStream(문자열 sysID) {#ariaid-title14}

첨부 파일 sys_id이 지정된 GlideScriptableInputStream 객체를 반환합니다.
[GlideTextReader](https://servicenow-prod.fluidtopics.net/264hbrveEhEQV3vcU5whxw#c_GlideTextReaderScopedAPI "GlideTextReader API는 입력 스트림에서 한 줄을 읽을 수 있는 기능을 제공합니다. 입력 스트림이 사용되기 때문에 5MB의 첨부 파일 크기 제한이 적용되지 않습니다.") API를 사용하여 콘텐츠 스트림을 읽을 수 있습니다.
{#r_SGSA-getContentStream_S__id_xhr_q4z_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysID | 문자열 | 첨부 파일 sys_id. |
[표 24. 매개변수]

{#r_SGSA-getContentStream_S__id_xhr_q4z_g5b} {#r_SGSA-getContentStream_S__id_yry_q4z_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| GlideScriptableInputStream | 첨부 파일 콘텐츠가 포함된 스트림입니다. |
[표 25. 반환]

{#r_SGSA-getContentStream_S__id_yry_q4z_g5b}  

    var attachment = new GlideSysAttachment();
    var attachmentSysID = '6e4621df1bc420501363ff37dc4bcbb0';
    var attachmentContentStream = attachment.getContentStream(attachmentSysID);
    gs.info('Attachment content stream: ' + attachmentContentStream);

출력:

    Attachment content stream: com.glide.communications.GlideScriptableInputStream@14bd299

## 범위가 지정된 GlideSysAttachment - updateAllAttributes(String, sysAttachmentID, Object, attrsKeyValuePair) {#ariaid-title15}

기존 첨부 파일 기록의 모든 속성을 업데이트합니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAttribute_S_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")

{#SGSA-updateAllAttributes_S_O__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - updateAllAttributes(객체 attrsKeyValuePair)](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-updateAllAttributes_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")
{#SGSA-updateAllAttributes_S_O__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
| attrs키값쌍 | 객체 | 키-값 쌍 집합의 첨부 파일 속성입니다. 각 속성 키와 해당 값은 문자열로 제공되어야 합니다. 예: var attachmentAttributes = { "description" : "Photo of the solar system", "dimensions" : "1600 x 300" } |
[표 26. 매개변수]

{#SGSA-updateAllAttributes_S_O__table_rql_3mg_5fc} {#SGSA-updateAllAttributes_S_O__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| 없음 |   |
[표 27. 반환]

{#SGSA-updateAllAttributes_S_O__table_sql_3mg_5fc}  
다음 예제에서는 지정된 첨부 파일에 대해 각 속성을 업데이트하는 방법을 보여 줍니다. 첨부 파일 속성 \[sys_attachment_attribute\] 테이블에서도 결과를 확인할 수 있습니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    var attachmentAttributes = {
        "category" : "Training",
        "title" : "Updating attachment attributes", 
        "author" : "Abraham Lincoln",
        "length" : "6000"
    }

    attach.updateAllAttributes(attachmentID, attachmentAttributes);

    var result = attach.fetchAllAttributes(attachmentID);

    while(result.next()) {
       gs.info("Key: " + result.getValue('key') + ", Value: " + result.getValue('value'));
    }

출력:

    Key: title, Value: Updating attachment attributes
    Key: author, Value: Abraham Lincoln
    Key: category, Value: Training
    Key: length, Value: 6000

## 범위가 지정된 GlideSysAttachment - updateAttribute(String sysAttachmentID, String attrKey, String attrValue) {#ariaid-title16}

기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.
참조 :

* [addAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addAttribute_S_S_S "기존 첨부 파일 기록에 단일 속성을 추가합니다.")
* [addMultipleAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-addMultipleAttributes_S_O "첨부 파일 기록에 여러 속성을 추가합니다.")
* [deleteAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAllAttributes_S "기존 첨부 파일 기록에서 모든 속성을 삭제합니다.")
* [delete속성()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-deleteAttribute_S_S "첨부 파일 기록에서 지정된 속성을 삭제합니다.")
* [fetchAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAllAttributes_S "지정된 첨부 파일 기록에서 모든 속성을 가져옵니다.")
* [fetchAttribute()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-fetchAttribute_S_S "첨부 파일 기록에서 지정된 속성을 가져옵니다.")
* [updateAllAttributes()](https://servicenow-prod.fluidtopics.net/D1kQG6kQFJyPO8959vQTiw#SGSA-updateAllAttributes_S_O "기존 첨부 파일 기록의 모든 속성을 업데이트합니다.")

{#SGSA-updateAttribute_S_S_S__ul_uwj_4yq_zfc}이 메서드와 전역 버전에 해당하는 경우 .[GlideSysAttachment - updateAttribute(String attrKey, String attrValue)](https://servicenow-prod.fluidtopics.net/_n3dUJbA~iPACJE6~pgufA#GSA-updateAttribute_S_S "기존 첨부 파일 기록에 대한 단일 속성을 업데이트합니다.")
{#SGSA-updateAttribute_S_S_S__table_rql_3mg_5fc__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysAttachmentID | 문자열 | 첨부 파일 \[sys_attachment\] 테이블에 나열된 첨부 파일의 Sys_id입니다. |
| 속성 키 | 문자열 | 첨부 파일 속성에 대한 키-값 쌍의 키 부분입니다. |
| 속성 값 | 문자열 | 첨부 파일 속성에 대한 키-값 쌍의 값 부분입니다. |
[표 28. 매개변수]

{#SGSA-updateAttribute_S_S_S__table_rql_3mg_5fc} {#SGSA-updateAttribute_S_S_S__table_sql_3mg_5fc__entry__2}

| 유형 | 설명 |
|-|-|
| 없음 |   |
[표 29. 반환]

{#SGSA-updateAttribute_S_S_S__table_sql_3mg_5fc}  
다음 예제에서는 지정된 첨부 파일에 할당된 특성을 <kbd class="ph userinput">author</kbd> 키를 사용하여 업데이트하고 값을 Abel Tuter로 변경하는 방법을 보여 줍니다. 첨부 파일 속성 \[sys_attachment_attribute\] 테이블에서도 결과를 확인할 수 있습니다.

    var attach = new GlideSysAttachment();

    var attachmentID = '9e1b714601932210f877b455304df0af';

    var originalVal = attach.fetchAttribute(attachmentID, "author");
    while(originalVal.next()) {
       gs.info("Original attribute value: " + originalVal.getValue('value') + "\n"); 
    }

    attach.updateAttribute(attachmentID, "author", "Abel Tuter");

    var updatedVal = attach.fetchAttribute(attachmentID, "author"); 
    while(updatedVal.next()) {
       gs.info("Updated attribute value: " + updatedVal.getValue('value')); 
    }

출력:

    Original attribute value: Fred Luddy

    Updated attribute value: Abel Tuter

## 범위가 지정된 GlideSysAttachment - write(GlideRecord record, String fileName, String contentType, String content) {#ariaid-title17}

지정된 첨부 파일을 지정된 기록에 첨부합니다.
{#r_SGSA-write_GR_S_S_S__id_zx4_v4z_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 기록 | GlideRecord | 첨부 파일을 첨부할 기록입니다. |
| fileName | 문자열 | 첨부 파일 이름입니다. |
| contentType | 문자열 | 첨부 파일의 MIME 유형입니다( `예: image/png`). 첨부 파일 \[sys_attachment\] 테이블의 콘텐츠 유형 필드에 있습니다. |
| 컨텐츠 | 문자열 | 첨부 파일 컨텐츠입니다. |
[표 30. 매개변수]

{#r_SGSA-write_GR_S_S_S__id_zx4_v4z_g5b} {#r_SGSA-write_GR_S_S_S__id_rnx_v4z_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 첨부 파일 sys_id. 첨부 파일이 추가되지 않은 경우 null을 반환합니다. |
[표 31. 반환]

{#r_SGSA-write_GR_S_S_S__id_rnx_v4z_g5b}  

    var attachment = new GlideSysAttachment();

    //set up inputs
    var rec = new GlideRecord('incident');
    rec.get('78271e1347c12200e0ef563dbb9a7109');
    var fileName = 'example.txt';
    var contentType = 'text/csv';
    var content = 'The text that is stored inside my file';

    var agr = attachment.write(rec, fileName, contentType, content);

    gs.info('The attachment sys_id is: ' + agr);

출력:

    The attachment sys_id is: 01271e4317c13311e0ef563dbb9abe34

## 범위가 지정된 GlideSysAttachment - writeBase64(GlideRecord now_GR, 문자열 fileName, 문자열 contentType, 문자열 content_base64Encoded) {#ariaid-title18}

base64 인코딩 콘텐츠를 사용하여 지정된 기록에 대한 첨부 파일을 삽입합니다.
{#r_SGSA-writeBase64_GR_S_S_S__table_nfx_fwx_hx__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| now_GR | GlideRecord | 첨부 파일을 첨부할 기록입니다. |
| fileName | 문자열 | 첨부 파일 이름입니다. |
| contentType | 문자열 | 첨부 파일의 MIME 유형입니다( `예: image/png`). 첨부 파일 \[sys_attachment\] 테이블의 콘텐츠 유형 필드에 있습니다. |
| 컨텐츠 | 문자열 | base64 형식의 첨부 파일 컨텐츠입니다. |
[표 32. 매개변수]

{#r_SGSA-writeBase64_GR_S_S_S__table_nfx_fwx_hx} {#r_SGSA-writeBase64_GR_S_S_S__table_ofx_fwx_hx__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 생성된 첨부 파일의 Sys_id입니다. |
[표 33. 반환]

{#r_SGSA-writeBase64_GR_S_S_S__table_ofx_fwx_hx}  

    var attachment = new GlideSysAttachment();

    var rec = new GlideRecord('incident');
    var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
    rec.get(incidentSysID);
    var fileName = 'example.txt';
    var contentType = 'text/csv';
    var base64Encodedcontent = 'SSBhbSB0ZXh0Lg==';

    var agr = attachment.writeBase64(rec, fileName, contentType, base64Encodedcontent);

    gs.info('The attachment sys_id is: ' + agr);

출력:

    The attachment sys_id is: 10cde9971b0820501363ff37dc4bcba6

## 범위가 지정된 GlideSysAttachment - writeContentStream(GlideRecord now_GR, 문자열 fileName, 문자열 contentType, GlideScriptableInputStream inputStream) {#ariaid-title19}

입력 스트림을 사용하여 첨부 파일을 삽입합니다.
{#r_SGS-writeContentStrm_GR_S_S_GSIS__id_n5v_npz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| now_GR | GlideRecord | 첨부 파일을 첨부할 기록입니다. |
| fileName | 문자열 | 첨부 파일 이름입니다. |
| contentType | 문자열 | 첨부 파일의 MIME 유형입니다( `예: image/png`). 첨부 파일 \[sys_attachment\] 테이블의 콘텐츠 유형 필드에 있습니다. |
| 컨텐츠 | GlideScriptableInputStream | 첨부 파일 컨텐츠입니다. |
[표 34. 매개변수]

{#r_SGS-writeContentStrm_GR_S_S_GSIS__id_n5v_npz_g5b} {#r_SGS-writeContentStrm_GR_S_S_GSIS__id_lkf_npz_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 생성된 첨부 파일의 Sys_id입니다. |
[표 35. 반환]

{#r_SGS-writeContentStrm_GR_S_S_GSIS__id_lkf_npz_g5b}  
sys_attachment 테이블의 콘텐츠 스트림을 test_table 기록에 첨부합니다.

    function copyAttachmentToGlideRecord(conceptSysId) {

      // Get record from test_table using sys_id
      var targetGlideRecord = new GlideRecord("test_table");
      if (!targetGlideRecord.get(conceptSysId)) {
         throw ("Cannot find record created by test with sys_id: " + conceptSysId);
      }

      // Get record from sys_attachment table
      var sourceAttachmentGlideRecord = new GlideRecord('sys_attachment');    
      sourceAttachmentGlideRecord.query();
      sourceAttachmentGlideRecord.next();

      // Get field values from retrieved sys_attachment record
      var fileName = sourceAttachmentGlideRecord.getValue('file_name');
      var contentType = sourceAttachmentGlideRecord.getValue('content_type');
      var sourceAttachmentSysId = sourceAttachmentGlideRecord.getValue('sys_id');

      // Attach sys_attachment record content stream to test_table record
      var gsa = new GlideSysAttachment();
      gsa.writeContentStream(
        targetGlideRecord,
        fileName,
        contentType,
        gsa.getContentStream(sourceAttachmentSysId));
      gs.info("Attachment created");
    }


