ServiceNow Fluent
도메인별 프로그래밍 언어를 사용하여 소스 코드에서 애플리케이션 메타데이터를 정의합니다.ServiceNow Fluent
ServiceNow Fluent 개요
ServiceNow Fluent 은 애플리케이션을 구성하는 메타데이터 파일 [sys_metadata]을 정의하기 위한 TypeScript를 기반으로 하는 선언적 DSL(도메인별 언어)이며 테이블, 역할, ACL, 비즈니스 규칙 및 Automated Test Framework 테스트와 같은 다양한 유형의 메타데이터에 대한 API를 포함합니다.
개발자는 양식이나 작성기 도구 사용자 인터페이스를 사용하는 대신 몇 줄의 코드로 이 메타데이터를 정의합니다. 에서 개발ServiceNow Fluent을 지원하거나 ServiceNow SDK 사용하여 생성되거나 변환된 ServiceNow IDE 애플리케이션입니다.
ServiceNow Fluent 는 양방향 동기화를 지원하므로 메타데이터의 변경 사항은 다른 ServiceNow AI Platform 사용자 인터페이스에서 소스 코드로 동기화되고 소스 코드의 변경 사항은 인스턴스 전체의 메타데이터로 다시 동기화됩니다.
OR 사용을 ServiceNow IDE 시작하려면 OR ServiceNow SDKServiceNow SDK 설명서를 참조하십시오ServiceNow IDE.
ServiceNow Fluent개 API
ServiceNow Fluent 에는 다양한 유형의 메타데이터에 대한 API가 포함되어 있습니다. 기록 API를 사용하여 전용 API가 없는 애플리케이션 메타데이터를 정의할 수 있습니다. 지원되는 API 및 예제의 최신 목록은 ServiceNow Fluent 의 API 참조 및 ServiceNow SDK 예제 리포지토리GitHub를 참조하십시오.
ServiceNow Fluent 사용법
.now.ts 확장명이 있는 파일에서는 API의 객체를 ServiceNow Fluent 사용하여 애플리케이션의 메타데이터를 정의합니다. 또한 @servicenow/sdk/core의 API에 필요한 임포트를 포함해야 합니다. BusinessRule 개체처럼 서버 측 스크립트가 있는 개체의 경우 JavaScript 모듈에서 코드를 임포트하여 사용할 수 있습니다.
import '@servicenow/sdk/global'
import { BusinessRule, ClientScript, DateColumn, StringColumn, Table } from '@servicenow/sdk/core'
import { showStateUpdate } from '../server/script.js'
//creates todo table, with three columns (deadline, status and task)
export const x_snc_example_to_do = Table({
name: 'x_snc_example_to_do',
schema: {
deadline: DateColumn({ label: 'Deadline' }),
state: StringColumn({
label: 'State',
choices: {
ready: { label: 'Ready' },
completed: { label: 'Completed' },
inProgress: { label: 'In Progress' },
},
}),
task: StringColumn({ label: 'Task', maxLength: 120 }),
},
})
//creates a client script that pops up 'Table loaded successfully!!' message everytime todo record is loaded
ClientScript({
$id: Now.ID['cs0'],
name: 'my_client_script',
table: 'x_snc_example_to_do',
active: true,
appliesExtended: false,
global: true,
uiType: 'all',
description: 'Custom client script generated by Now SDK',
isolateScript: false,
type: 'onLoad',
script: Now.include('../client/client-script.js'),
})
//creates a business rule that pops up state change message whenever a todo record is updated
BusinessRule({
$id: Now.ID['br0'],
action: ['update'],
table: 'x_snc_example_to_do',
script: showStateUpdate,
name: 'LogStateChange',
order: 100,
when: 'after',
active: true,
})function onLoad() {
g_form.addInfoMessage("Table loaded successfully!!")
}import { gs } from '@servicenow/glide'
export function showStateUpdate(current, previous) {
const currentState = current.getValue('state')
const previousState = previous.getValue('state')
gs.addInfoMessage(`state updated from "${previousState}" to "${currentState}"`)
}애플리케이션을 빌드한 후 이 소스 코드는 인스턴스에 다음과 같은 애플리케이션 메타데이터 파일을 생성합니다.
@fluent-ignore: 다음 코드 줄에서 진단 경고 및 오류를 표시하지 ServiceNow Fluent 않습니다.@fluent-disable-sync: 객체에 ServiceNow Fluent 대한 변경 내용 동기화를 끕니다. 호출 식(예:Record({ ... })) 앞에 사용하여 해당 객체와 해당 하위 객체에 대한 동기화를 끕니다. 객체에 대한 소스 코드 외부의 변경 사항을 무시하고 동기화할 때 업데이트하지 않으려는 경우에만 이 지시문을 사용하십시오.@fluent-disable-sync-for-file: 파일에 대한 ServiceNow Fluent 변경 내용 동기화를 끕니다(.now.ts). 파일의 첫 번째 줄에서 사용하여 파일의 모든 코드 동기화를 끕니다. 소스 코드 외부에서 파일에 대한 변경 사항을 무시하고 동기화할 때 업데이트하지 않으려는 경우에만 이 지시문을 사용하십시오.