モバイル GlideForm (g_form): クライアント
Mobile GlideForm (g_form) API は、モバイルプラットフォームでフォームを操作するためのメソッドを提供します。
これらのメソッドは、モバイルデバイスをターゲットとする任意のスクリプトで使用します。
MobileGlideForm (g_form) - addDecoration(String fieldName, String icon, String text)
フィールドの横に装飾アイコンを追加します。
| 名前 | タイプ | 説明 |
|---|---|---|
| fieldName | 文字列 | フィールド名 |
| icon | 文字列 | フィールドの横に表示するフォントアイコン。 |
| テキスト | 文字列 | アイコンのテキストタイトル (スクリーンリーダーに使用)。 |
| タイプ | 説明 |
|---|---|
| なし |
この例では、発信者の横に VIP アイコンを追加します。
function onChange(control, oldValue, newValue, isLoading) {
// if the caller_id field is not present, then we can't add an icon anywhere
if (!g_form.hasField('caller_id'))
return;
if (!newValue)
return;
g_form.getReference('caller_id', function(ref) {
g_form.removeDecoration('caller_id', 'icon-star', 'VIP');
if (ref.getValue('vip') == 'true')
g_form.addDecoration('caller_id', 'icon-star', 'VIP');
});
}
MobileGlideForm (g_form) - getLabel(文字列 fieldName)
フォームラベルテキストを取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| fieldName | 文字列 | フィールド名 |
| タイプ | 説明 |
|---|---|
| 文字列 | ラベルテキスト。 |
if (g_user.hasRole('itil')) {
var oldLabel = g_form.getLabel('comments');
g_form.setLabel('comments', oldLabel + ' (Customer visible)');
}
MobileGlideForm (g_form) - hasField(文字列 fieldName)
フィールドがフォームに存在するかどうかを判定します。
存在するということは、表示できるということではなく、表示できることを意味します。
| 名前 | タイプ | 説明 |
|---|---|---|
| fieldName | 文字列 | 検索するフィールド。 |
| タイプ | 説明 |
|---|---|
| ブーリアン | フィールドがフォームに存在する場合は True。そうでない場合は false。フォーム上にあるということは、フィールドがg_formの一部であることを意味します。これは、非表示、読み取り専用、必須、または無効である可能性があります。 |
この例では、[assignment_group] フィールドがフォーム上にある場合、[assigned_to] フィールドを必須にします。
if (g_form.hasField('assignment_group'))
g_form.setMandatory('assigned_to', true);
MobileGlideForm (g_form) - removeDecoration(String fieldName, String icon, String text)
フィールドの横から装飾アイコンを削除します。
| 名前 | タイプ | 説明 |
|---|---|---|
| fieldName | 文字列 | フィールド名 |
| icon | 文字列 | 削除するアイコン。 |
| テキスト | 文字列 | アイコンのテキストタイトル。 |
| タイプ | 説明 |
|---|---|
| なし |
function onChange(control, oldValue, newValue, isLoading) {
// if the caller_id field is not present, then we can't add an icon anywhere
if (!g_form.hasField('caller_id'))
return;
if (!newValue)
return;
g_form.getReference('caller_id', function(ref) {
g_form.removeDecoration('caller_id', 'icon-star', 'VIP');
if (ref.getValue('vip') == 'true')
g_form.addDecoration('caller_id', 'icon-star', 'VIP');
});
}
MobileGlideForm (g_form) - setLabel(文字列 fieldName, 文字列ラベル)
フォームラベルテキストを設定します。
| 名前 | タイプ | 説明 |
|---|---|---|
| fieldName | 文字列 | フィールド名 |
| label | 文字列 | フィールドラベルのテキスト。 |
| タイプ | 説明 |
|---|---|
| なし |
この例では、コメントラベルを変更します。
if (g_user.hasRole('itil')) {
var oldLabel = g_form.getLabel('comments');
g_form.setLabel('comments', oldLabel + ' (Customer visible)');
}