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

 Release :

    - xanadu

ft:locale :

    - ko-KR

ft:publication_title :

    - Xanadu API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# 인스턴스의 ServiceNow 테이블 데이터와 상호작용

# 인스턴스의 ServiceNow 테이블 데이터와 상호작용 {#ariaid-title1}

* 릴리스 버전: Xanadu
* 
* 업데이트 날짜 2024년 08월 01일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 6분

이를 Mobile SDK 통해 인스턴스에 있는 테이블의 데이터와 상호작용할 수 있습니다 ServiceNow . REST 인터페이스를 직접 호출하는 NowTableService() API를 사용하거나 REST GraphQL API에 대해 지정된 GraphQL 쿼리를 실행하는 NowGraphQLService() API를 통해 REST 테이블 API를 통해 ServiceNow 이 데이터와 상호 작용할 수 있습니다.
단일 호출 내에서 여러 테이블의 데이터를 반환하려면 NowGraphQLService() API를 사용해야 합니다. Table API 이외의 REST API와 ServiceNow 상호 작용해야 하는 경우 을 참조하십시오[인스턴스에서 공용 REST API와 ServiceNow 상호 작용](https://servicenow-prod.fluidtopics.net/1Q1bOOn_IOSGGwgxRvezQQ "Mobile SDK 애플리케이션이 인스턴스에서 ServiceNow 공용 REST API를 호출할 수 있도록 Android 하는 기능을 제공합니다.").

## NowGraphQLService를 사용하여 테이블과 ServiceNow 상호작용 {#mobsdk-and-interact_data_instance__section_kxm_wdf_hqb}

[NowGraphQLService](https://servicenow-prod.fluidtopics.net/hNwabriy8wsff6YlkesNhA#NowGQLServiceAndroidInterface "NowGraphQLService 인터페이스는 GraphQL API를 통해 GraphQL을 요청할 수 ServiceNow 있는 기능을 제공합니다.") 클래스는 로그인한 사용자에게 적절한 권한이 있는 경우 인스턴스 내의 ServiceNow 지정된 테이블에서 GraphQL 쿼리를 구성하고 실행할 수 있는 메서드를 제공합니다. GraphQL 쿼리 내에서 모든 CRUD 작업을 정의할 수 있습니다.  
다음 예제에서는 NowData 프레임워크를 가져온 다음 인스턴스의 테이블과 상호 작용하는 데 사용할 수 있는 NowGraphQLService 개체를 초기화하는 방법을 보여 줍니다 ServiceNow .

    /**
     * Helper class used to handle different Now service instances.
     */
    @Singleton
    class SdkManager @Inject constructor() {

        private var nowGraphQLService: NowGraphQLService? = null

        /**
         * Create the NowGraphQLService once in the lifetime of the application inside the Application class or another manager class
         * that will be injected into other classes via dagger/hilt.
         * NowGraphQLService should be created after initializing the NowSDK
         */
        suspend fun getNowGraphQLService(): NowGraphQLService? {
            if (nowGraphQLService != null) return nowGraphQLService

            return NowDataSDK.makeGraphQLService(URL("https://instance-name.service-now.com")).getOrThrow()
                .also { this.nowGraphQLService = it }
        }
    }

이 예제에서는 GraphQL 쿼리를 사용하여 게시된 KB 문서를 가져오는 방법을 보여 줍니다.

    suspend fun loadList() = withContext(Dispatchers.IO) {
        val kbArticlesQuery = """
        { 
            GlideRecord_Query {
                kb_knowledge(queryConditions: "active=true^ORDERBYpublishedDESC"
                pagination:{ limit: 10, offset: 0 }) {
                    _results {
                        sys_id { value },
                        number { displayValue },
                        short_description { displayValue },
                        author { displayValue }
                        published { displayValue }
                    }
                }
            }
         }
     """
        val graphQLService = sdkManager.getNowGraphQLService()

        //graphQLService?.graphQLRequest(kbArticlesQuery)?.execute() can also be used
        graphQLService?.graphQLRequest(kbArticlesQuery)?.enqueue(
            { response ->
                response.body?.let {
                    val resultString = String(it)
                }

            }, { nowDataError ->
                //handle error
            })
    }

## NowTableService를 사용하여 테이블과 ServiceNow 상호 작용 {#mobsdk-and-interact_data_instance__section_fgn_gy2_hqb}

[NowTableService](https://servicenow-prod.fluidtopics.net/HpSdCXZeZ5jUoUqfhZOG_Q#NowTableServiceAndroidInterface "NowTableService 인터페이스는 인스턴스의 테이블 ServiceNow 내에서 레코드를 만들고, 읽고, 삭제하고, 업데이트할 수 있는 함수를 제공합니다.") 클래스는 인스턴스에 상주 ServiceNow 하는 테이블의 레코드에 대해 CRUD 작업을 수행하는 메서드를 제공합니다. 이 인터페이스를 통해 로그인한 사용자에게 권한이 부여된 테이블 ServiceNow 내의 모든 기록에 직접 액세스할 수 있습니다. NowTableService 는 참조 필드에 대한 닷워킹을 지원합니다. 예를 들어 테이블에 사용자 테이블에 대한 참조가 포함되어 있는 경우 닷워킹 값은 `user.name` 사용자의 이름을 반환합니다.

요청된 데이터를 반환할 때 적용 가능한 모든 ACL(접근 제어 목록)이 데이터에 적용되므로 결과가 예상보다 적거나 인증된 사용자에게 지정된 테이블에 대한 액세스 권한이 없는 경우 권한 부여 오류가 발생할 수 있습니다.  
다음 예제에서는 NowData 프레임워크를 가져온 다음 인스턴스 테이블과 ServiceNow 상호 작용하는 데 사용할 수 있는 NowTableServce 개체를 초기화하는 방법을 보여 줍니다.

    /**
     * Helper class used to handle different Now service instances. It has an application scope or is Singleton
     */
    @Singleton
    class SdkManager @Inject constructor() {

        private var nowTableService: NowTableService? = null

        /**
         * Create the NowTableService once in the lifetime of the application inside the Application class or another manager class
         * that will be injected into other classes via dagger/hilt.
         * NowTableService should be created after initializing the NowSDK
         */
        suspend fun getNowTableService(): NowTableService? {
            if (nowTableService != null) return nowTableService

            return NowDataSDK.makeTableService(URL("https://instance-name.service-now.com")).getOrThrow()
                .also { this.nowTableService = it }
        }
     }    


    suspend fun loadCases() = withContext(Dispatchers.IO) {
        val tableService = sdkManager.getNowTableService()

        //configure what data to pass back
        val fetchConfiguration =  FetchConfiguration(Filter("active=true"), 10)

        val response = runCatching {
            tableService?.records(
                "sn_customerservice_case",
                fetchConfiguration
            )?.execute()
        }

        if (response.isSuccess) {
            val resultString = response.getOrNull()?.body?.let { String(it) }
        } else {
            //handle unsuccessful result
        }
    }

사용 가능한 NowTableService 메서드를 사용하는 추가 코드 예제는 [NowTableService](https://servicenow-prod.fluidtopics.net/HpSdCXZeZ5jUoUqfhZOG_Q#NowTableServiceAndroidInterface "NowTableService 인터페이스는 인스턴스의 테이블 ServiceNow 내에서 레코드를 만들고, 읽고, 삭제하고, 업데이트할 수 있는 함수를 제공합니다.") API 설명서를 참조하세요.

