GlideElement - スコープ指定
スコープ付き GlideElement API には、フィールドとその値を処理するための便利なスクリプトメソッドが多数用意されています。現在の Glide レコードのフィールドで、スコープ指定された GlideElement メソッドを使用できます。
スコープ対象 GlideElement - canCreate()
ユーザーのロールで関連付けられたフィールドでの新しいエントリの作成が可能かどうかを判断します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| ブーリアン | 現在のユーザーが関連フィールドに新しいエントリを作成する権限を持っているかどうかを示すフラグ。 可能な値:
|
次の例は、ユーザーが問題 [problem] テーブルの最新の 3 つのレコードのエントリを作成する権限を持っているかどうかを判断する方法を示しています。
var gr = new GlideRecord('problem');
// Get records in new state in Problem Table
gr.addQuery('state','101');
// Sort records in order of recent to earlier Created Date
gr.orderByDesc('sys_created_on');
// Limit the query to three records
gr.setLimit(3);
gr.query();
while(gr.next()){
if(gr.short_description.canCreate()){ ///check to see if the current user is allowed to create the record
gs.info("I can create new records for the field Problem statement for - " + gr.number);
}
}
出力:
I can create new records for the field Problem statement for - PRB0000004
I can create new records for the field Problem statement for - PRB0001000
I can create new records for the field Problem statement for - PRB0001001
スコープ対応
スコープ対象のアプリケーションで canCreate() メソッドを使用するには、対応するスコープ対象のメソッド canCreate() を使用します。
スコープ対象 GlideElement - canRead()
ユーザーのロールで関連する GlideRecord の読み取りが可能かどうかを示します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| ブーリアン | フィールドが読み込み可能な場合は true、可能でない場合は false。 |
次の例は、読み取り可能な [簡単な説明] フィールドを持つアクティブなインシデントレコードリストを取得する方法を示しています。
var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery("active=true"); //Query the Incident table for active incidents
grIncident.orderByDesc('number');
grIncident.setLimit(3); // limit to three results for example
grIncident.query();
while (grIncident.next()) {
if (grIncident.short_description.canRead()) { //check to see if the current user is allowed to read the record
gs.info('You have permission to read the short description of: ' + grIncident.number + ' ' + grIncident.short_description);
}
}
出力:
*** Script: You have permission to read the short description of: INC0009009 Unable to access the shared folder.
*** Script: You have permission to read the short description of: INC0009005 Email server is down.
*** Script: You have permission to read the short description of: INC0009001 Unable to post content on a Wiki page
スコープ対象 GlideElement - canWrite()
ユーザーのロールで関連する GlideRecord の書き込みが可能かどうかを判断します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| ブーリアン | フィールドに書き込み可能な場合は true、可能でない場合は false。 |
次の例は、書き込み可能な [簡単な説明] フィールドを持つアクティブなインシデントレコードリストを取得する方法を示しています。
var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery("active=true"); //Query the Incident table for active incidents
grIncident.orderByDesc('number');
grIncident.setLimit(3); // limit to three results for example
grIncident.query();
while (grIncident.next()) {
if (grIncident.short_description.canWrite()) { //check to see if the current user is allowed to write to the record
gs.info('You have permission to write to the short description of: ' + grIncident.number + ' ' + grIncident.short_description);
}
}
出力:
*** Script: You have permission to write to the short description of: INC0009009 Unable to access the shared folder.
*** Script: You have permission to write to the short description of: INC0009005 Email server is down.
*** Script: You have permission to write to the short description of: INC0009001 Unable to post content on a Wiki page
スコープ対象 GlideElement - changes()
現在のフィールドが変更されているかどうかを判断します。この機能は、ジャーナルフィールドを除くすべての利用可能なデータタイプで使用できます。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| ブーリアン | フィールドが変更されている場合は true、フィールドが変更されていない場合は false。 |
ビジネスルールからの次の例は、[assigned_to] フィールドの値が変更された場合に EventQueue にイベントを作成する方法を示しています。
if (!current.assigned_to.nil() && current.assigned_to.changes()) {
gs.eventQueue('incident.assigned', current, current.assigned_to.getDisplayValue(), previous.assigned_to.getDisplayValue());
}
スコープ対象 GlideElement - changesFrom(オブジェクト o)
現在のフィールドの前の値が指定されたオブジェクトと一致するかどうかを判断します。
| 名前 | タイプ | 説明 |
|---|---|---|
| o | オブジェクト | 現在のフィールドの前の値と照合するオブジェクト値。 |
| タイプ | 説明 |
|---|---|
| ブーリアン | 前の値が一致する場合は true、一致しない場合は false。 |
// The following example shows that in a business rule, if "active" field is changed from true,
// insert a event in the EventQueue.
if (current.active.changesFrom(true)) {
gs.eventQueue("incident.inactive", current, current.incident_state, previous.incident_state);
}
スコープ対象 GlideElement - changesTo(オブジェクト o)
変更後のフィールドの新しい値が指定されたオブジェクトと一致するかどうかを判断します。
| 名前 | タイプ | 説明 |
|---|---|---|
| o | オブジェクト | 現在のフィールドの新しい値と照合するオブジェクト値。 |
| タイプ | 説明 |
|---|---|
| ブーリアン | 前の値が一致する場合は true、一致しない場合は false。 |
// The following example shows that in a business rule, if "active" field is changed to false,
// insert a event in the EventQueue.
if (current.active.changesTo(false)) {
gs.eventQueue("incident.inactive", current, current.incident_state, previous.incident_state);
}
スコープ対象 GlideElement - dateNumericValue()
期間フィールドに対して 1970 年 1 月 1 日 00:00:00 GMT 以降のミリ秒数を返します。期間フィールドはすでに GlideDateTime オブジェクトであるため、GlideDateTime オブジェクトを作成する必要はありません。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 数値 | 1970 年 1 月 1 日 00:00:00 GMT 以降のミリ秒数。 |
var inc = new GlideRecord('incident');
inc.get('17c90efb13418700cc36b1422244b05d');
gs.info(inc.calendar_duration.dateNumericValue());
出力:
98000
スコープ対象 GlideElementget - getAttribute(文字列 attributeName)
指定された属性の値をディクショナリから返します。
属性がブーリアン属性の場合は、getBooleanAttribute(文字列) を使用して、値を文字列ではなくブーリアンとして取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| attributeName | 文字列 | 属性の名前 |
| タイプ | 説明 |
|---|---|
| 文字列 | 属性値 |
doit();
function doit() {
var now_GR = new GlideRecord('sys_user');
now_GR.query("user_name","admin");
if (now_GR.next()) {
gs.info("we got one");
gs.info(now_GR.location.getAttribute("tree_picker"));
}
}
スコープ対象 GlideElementget - getBooleanAttribute(文字列 attributeName)
指定された属性のブーリアン値をディクショナリから返します。
値を文字列として取得するには、getAttribute(文字列) を使用します。
| 名前 | タイプ | 説明 |
|---|---|---|
| attributeName | 文字列 | 属性の名前 |
| タイプ | 説明 |
|---|---|
| ブーリアン | 属性のブーリアン値。属性が存在しない場合は false を返します。 |
次の例は、2 つのフィールドの ignore_filter_on_new 属性のブール値を取得する方法を示しています。
var inc = new GlideRecord('incident');
inc.query();
if (inc.next())
{
// opened_by field has attribute "ignore_filter_on_new = true"
gs.info(inc.opened_by.getBooleanAttribute("ignore_filter_on_new"));
// short_description field does not have attribute ignore_filter_on_new
gs.info(inc.short_description.getBooleanAttribute("ignore_filter_on_new"));
}
出力:
true
false
スコープ対象 GlideElement - getChoices(文字列 dependent)
指定されたフィールドの選択リストを返します。
選択リストを返すフィールドは、メソッド呼び出しで指定されます。例:var choices = glideRecord.urgency.getChoices();。選択リストフィールドタイプとそれに関連する機能については、 選択リストフィールドタイプを参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| dependent | 文字列 | オプション。選択リストフィールドが依存する関連レコード内のフィールド。 |
| タイプ | 説明 |
|---|---|
| アレイ | 選択リストの可能な値のリスト。これは、選択 [sys_choice] テーブルの値です。dependent パラメーターが渡された場合、返される結果には、指定された依存フィールドで利用可能な選択肢のみが反映されます。 |
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
// urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3
var choices = glideRecord.urgency.getChoices();
スコープ対象 GlideElement - getChoiceValue()
現在の選択の選択肢ラベルを返します。
選択には値 (数値) とラベル (文字列) があります。このメソッドはラベルを返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | 選択された選択肢のラベル。 |
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
// urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3
var choiceLabel = glideRecord.urgency.getChoiceValue();
gs.info(choiceLabel);
出力:
1 - High
スコープ対象 GlideElement - getDecryptedValue()
スコープ対象のアプリケーションでパスワード (双方向暗号化) フィールドのクリアテキスト値を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | クリアテキストのパスワード。 |
var tablename = 'x_scoped_app_table'
var CI = new GlideRecord(tablename);
CI.addQuery('number', '0001002');
CI.query();
CI.next();
var password = CI.password_field
var decrypted = password.getDecryptedValue();
gs.info(decrypted);
x_scoped_app: cleartextpasswordスコープ対象 GlideElement - getDisplayValue(数値 maxCharacters)
関連する GlideRecord オブジェクトから指定されたフィールドの書式設定された表示値を返します。
表示値は、データベース内の実際の値と、ユーザーやシステムの設定と環境設定に基づいて操作されます。
- 選択肢フィールド:データベース値は数値にできますが、表示値の方がわかりやすくなります。
- 日付フィールド:データベース値は UTC 形式で、表示値はユーザーのタイムゾーンに基づいたものになります。
- 暗号化テキスト:データベース値は暗号化されますが、表示値はユーザーの暗号化コンテキストに基づいて非暗号化されます。
- 参照フィールド:データベース値は sys_id ですが、表示値は参照レコードの表示フィールドになります。
表示値の詳細については、「 表示値」を参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| maxCharacters | 数値 | オプション。望ましい最大文字数。 デフォルト:すべて |
| タイプ | 説明 |
|---|---|
| 文字列 | 指定したフィールドの表示値。 |
次の例は、インシデントレコードの優先度フィールドの表示値を取得する方法を示しています。
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
gs.info(glideRecord.priority.getDisplayValue());
出力:
1 - Critical
次の例は、インシデントデータベース内の指定されたフィールドの表示値と内部値の両方を取得する方法を示しています。
var now_GR = new GlideRecord('incident');
now_GR.get('9c573169c611228700193229fff72400'); //INC0000001
gs.info('Display Values:');
gs.info('Opened at ' + now_GR.opened_at.getDisplayValue());
gs.info('Opened by ' + now_GR.opened_by.getDisplayValue());
gs.info('Priority ' + now_GR.priority.getDisplayValue());
gs.info('Values:');
gs.info('Opened at ' + now_GR.opened_at.getValue());
gs.info('Opened by ' + now_GR.opened_by.getValue());
gs.info('Priority ' + now_GR.priority.getValue());
出力:
Display Values:
Opened at 2022-02-01 15:09:51
Opened by Joe Employee
Priority 1 - Critical
Values:
Opened at 2022-02-01 23:09:51
Opened by 681ccaf9c0a8016400b98a06818d57c7
Priority 1
スコープ付き GlideElement - getDisplayValueLang (文字列言語)
パラメーターとして渡された言語でフィールドの表示値を取得します。
結果は、[ 選択肢]、[ 翻訳されたフィールド]、[ 翻訳されたテキスト] などの翻訳可能なフィールドタイプにのみ適用されます。他のフィールドタイプの場合、結果はデフォルトで getDisplayValue() になります。
翻訳された値を取得するには、対応する言語プラグインが必要です。詳細については、「Activate a language」を参照してください。
「スコープ付き GlideElement - getLabelLang (文字列言語)」も参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| 言語 | 文字列 | IETF BCP-47に準拠した言語タグです。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 渡された言語でのフィールドの表示値。翻訳が利用できない場合、メソッドは現在のユーザーの言語に翻訳された値を取得します。翻訳が利用できない場合、結果はデフォルトで英語になります。 |
次の例は、[ 承認 (UI ビュー)] タイトルフィールドから元のテキストとドイツ語に翻訳されたテキストを取得する方法を示しています。
var uiView = new GlideRecord("sys_ui_view");
uiView.get("fa776f6d97700100f309124eda2975bc");
gs.info("getDisplayValue: " + uiView.getElement("title").getDisplayValue());
gs.info("getDisplayValueLang: " + uiView.getElement("title").getDisplayValueLang("de"));
出力:
getDisplayValue: Accept
getDisplayValueLang: Akzeptieren
スコープ対象 GlideElement - getED()
フィールドの要素記述子を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| GlideElementDescriptor | フィールドの要素記述子。 |
var grInc = new GlideRecord('incident');
grInc.query('priority', '1');
var field = grInc.getElement('priority');
var ed = field.getED();
スコープ対象 GlideElement - getGlobalDisplayValue()
国際形式の電話番号を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | 国際形式の電話番号。 |
次の例は、Walk-up 場所の電話番号を取得する方法を示しています。この例には ウォークアップエクスペリエンス プラグインが必要です。
// Passing walkup location name and closed phone number in parameters
setWalkupLocPhone('Santa Clara Tech Lounge','phone_number');
function setWalkupLocPhone(locName, field) {
var walkupLoc = new GlideRecord('wu_location_queue');
walkupLoc.addQuery('name',locName);
walkupLoc.query();
walkupLoc.next();
// Returns the phone number of walk-up location queue in international format
gs.info(walkupLoc[field].getGlobalDisplayValue());
}
出力:
+91 98124 56789
スコープ対象 GlideElement - getHTMLValue(数値 maxChars)
フィールドの HTML 値を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| maxChars | 数値 | オプション。返される最大文字数。 |
| タイプ | 説明 |
|---|---|
| 文字列 | フィールドの HTML 値。 |
var inccause = new GlideRecord("incident");
inccause.short_description = current.short_description;
inccause.comments = current.comments.getHTMLValue();
inccause.insert();
スコープ対象 GlideElement - getJournalEntry(数値 mostRecent)
最新のジャーナルエントリまたはすべてのジャーナルエントリを返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| mostRecent | 数値 | 1 の場合、最新のエントリを返します。-1 の場合、すべてのジャーナルエントリを返します。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 最新のエントリの場合、ジャーナルエントリのフィールドラベル、タイムスタンプ、およびユーザー表示名を含む文字列を返します。 すべてのジャーナルエントリについて、これまでに入力されたすべてのジャーナルエントリに対する同じ情報を、各エントリが「\n\n」で区切られた単一の文字列として返します。 |
//gets all journal entries as a string where each entry is delimited by '\n\n'
var notes = current.work_notes.getJournalEntry(-1);
//stores each entry into an array of strings
var na = notes.split("\n\n");
for (var i = 0; i < na.length; i++)
gs.info(na[i]);
スコープ対象 GlideElement - getLabel()
オブジェクトのラベルを返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | オブジェクトのラベル |
var now_GR = new GlideRecord("sc_req_item");
now_GR.addQuery("request", current.sysapproval);
now_GR.query();
while(now_GR.next()) {
var nicePrice = now_GR.price.toString();
if (nicePrice != ) {
nicePrice = parseFloat(nicePrice);
nicePrice = nicePrice.toFixed(2);
}
template.print(now_GR.number + ": " + now_GR.quantity + " X " + now_GR.cat_item.getDisplayValue() + " at $" + nicePrice + " each \n");
template.print(" Options:\n");
var variables = now_GR.variables.getElements();
for (var key in variables) {
var now_V = variables[key];
if(now_V.getQuestion().getLabel() != ) {
template.space(4);
template.print(' ' + now_V.getQuestion().getLabel() + " = " + now_V.getDisplayValue() + "\n");
}
}
}
スコープ付き GlideElement - getLabelLang (文字列言語)
パラメーターとして渡された言語でフィールドのラベル値を取得します。
翻訳された値を取得するには、対応する言語プラグインが必要です。詳細については、「Activate a language」を参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| 言語 | 文字列 | IETF BCP-47に準拠した言語タグです。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 渡された言語のフィールドラベルの値。 翻訳が利用できない場合、メソッドは現在のユーザーの言語に翻訳された値を取得します。翻訳が利用できない場合、結果はデフォルトで英語になります。 |
次の例は、元のラベル テキストと、 Accept (UI ビュー) タイトルのドイツ語訳を取得する方法を示しています。
var uiView = new GlideRecord("sys_ui_view");
uiView.get("fa776f6d97700100f309124eda2975bc");
gs.info("getLabel: " + uiView.getElement("title").getLabel());
gs.info("getLabelLang: " + uiView.getElement("title").getLabelLang("de"));
出力:
getLabel: Title
getLabelLang: Titel
スコープ対象 GlideElement - getName()
フィールドの名前を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | フィールド名。 |
次の例は、sys_user レコードの各フィールドの名前とその他の値を取得する方法を示しています。
var userRec = new GlideRecord("sys_user"); // GlideRecord to sys_user table
userRec.get("5137153cc611227c000bbd1bd8cd2005"); // Sys Id of user: Fred Luddy
var fields = userRec.getFields();
for (var i = 0; i < fields.size(); i++) {
var field = fields.get(i);
var name = field.getName(); // Name of the field
var label = field.getLabel(); // Label of the field
var value = field.getDisplayValue(); // Value of the field
gs.info((Number(i) + 1) + ".\n" + "Field Label: " + label + "\n" + "Field Name: " + name + "\n" + "Field Value: " + value);
};
出力。結果には 62 個のフィールドが含まれており、スペースを節約するために省略記号 (…) が付けられています。
*** Script: 1.
Field Label: Country code
Field Name: country
Field Value:
*** Script: 2.
Field Label: Calendar integration
Field Name: calendar_integration
Field Value: Outlook
...
*** Script: 47.
Field Label: First name
Field Name: first_name
Field Value: Fred
...
*** Script: 54.
Field Label: Last name
Field Name: last_name
Field Value: Luddy
...
スコープ対象 GlideElement - getReferenceTable()
参照要素のテーブル名を取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | 参照のテーブル名。 |
var grINC = new GlideRecord('incident');
grINC.query('number','INC0010041'); // record assignment group assigned to "CAB Approval"
if (grINC.next()) {
// Get the table name
var tableName = grINC.assignment_group.getReferenceTable();
gs.info( tableName );
}
スコープ対象 GlideElement - getRefRecord()
指定された参照要素の GlideRecord オブジェクトを返します。
計算されたフィールドの場合、このメソッドは参照レコードをフェッチし、スクリプト化されたデフォルト値で計算を実行します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| GlideRecord | GlideRecord オブジェクト |
var grINC = new GlideRecord('incident');
grINC.addNotNullQuery('caller_id');
grINC.query();
if (grINC.next()) {
// Get a GlideRecord object for the referenced sys_user record
var grUSER = grINC.caller_id.getRefRecord();
if (grUSER.isValidRecord())
gs.info(grUSER.getValue('name'));
}
スコープ対象 GlideElement - getTableName()
フィールドが存在するテーブルの名前を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | テーブルの名前。返される値は、レコードが存在するテーブルクラスとは異なる場合があります。製品ドキュメントのテーブルとクラスを参照してください。 |
if (current.approver.getTableName() == "sysapproval_approver") {
if (current.approver == email.from_sys_id) {
current.comments = "reply from: " + email.from + "\n\n" + email.body_text;
// if it's been cancelled, it's cancelled.
var doit = true;
if (current.state=='cancelled')
doit = false;
if (email.body.state != undefined)
current.state= email.body.state;
if (doit)
current.update();
} else {
gs.log("Approval for task ("+current.sysapproval.getDisplayValue()+") rejected because user sending
email( "+email.from+") does not match the approver ("+current.approver.getDisplayValue()+")");
}
}
スコープ対象 GlideElement - nil()
フィールドが null かどうかを判断します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| ブーリアン | フィールドが null かどうかを示すフラグ。 可能な値:
|
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
gs.info(glideRecord.state.nil());
出力:
false
スコープ対象 GlideElement - setDateNumericValue(数値 milliseconds)
日時要素の値を 1970 年 1 月 1 日 00:00:00 GMT 以降のミリ秒数に設定します。
setDateNumericValue() が呼び出されると、必要な GlideDateTime/GlideDate/GlideDuration オブジェクトが自動的に作成され、要素が指定された値に設定されます。
| 名前 | タイプ | 説明 |
|---|---|---|
| milliseconds | 数値 | 1970 年 1 月 1 日以降のミリ秒数 |
| タイプ | 説明 |
|---|---|
| なし |
var now_GR = new GlideRecord("incident");
now_GR.initialize();
now_GR.opened_at.setDateNumericValue(10000);
スコープ対象 GlideElement - setDisplayValue(オブジェクト value)
フィールドの表示値を設定します。
| 名前 | タイプ | 説明 |
|---|---|---|
| value | オブジェクト | フィールドに設定する値。 |
| タイプ | 説明 |
|---|---|
| なし |
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
//change the urgency to 3
glideRecord.urgency.setDisplayValue('3 - Low');
gs.info(glideRecord.urgency);
スコープ対象 GlideElement - setError(文字列 errorMessage)
エラーメッセージを追加します。Fuji パッチ 3 で利用可能です。
| 名前 | タイプ | 説明 |
|---|---|---|
| errorMessage | 文字列 | エラーメッセージ。 |
| タイプ | 説明 |
|---|---|
| なし |
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
glideRecord.short_description.setError('Error text');
スコープ対象 GlideElement - setPhoneNumber(オブジェクト phoneNumber, ブーリアン strict)
フィールドを指定された電話番号に設定します。
このメソッドは、電話番号の GlideElement でのみ使用できます。
| 名前 | タイプ | 説明 |
|---|---|---|
| phoneNumber | オブジェクト | 設定する電話番号。国際形式またはローカル形式のいずれかになります。 |
| strict | ブーリアン | true の場合、指定された番号は正しい形式に一致する必要があります。false の場合、システムは不適切に書式設定された電話番号を修正しようとします。 |
| タイプ | 説明 |
|---|---|
| ブーリアン | 電話番号の値が設定されたかどうかを示すフラグ。 可能な値:
|
次の例は、Walk-up 場所の電話番号を設定する方法を示しています。この例には ウォークアップエクスペリエンス プラグインが必要です。
setWalkupLocPhone('Santa Clara Tech Lounge','+91 9812456789');
function setWalkupLocPhone(locName, phoneNumber) {
var walkupLoc = new GlideRecord('wu_location_queue');
walkupLoc.addQuery('name', locName);
walkupLoc.query();
walkupLoc.next();
// Set phone number of walk-up location
var isPhoneNumberSet = walkupLoc.phone_number.setPhoneNumber(phoneNumber, true);
walkupLoc.update();
gs.info('Phone Number: ' + walkupLoc.phone_number);
gs.info('Is phone number specified match the correct format: ' + isPhoneNumberSet);
}
出力:
Phone Number: +919812456789
Is phone number specified match the correct format: true
スコープ対象 GlideElement - setValue(オブジェクト value)
フィールドの値を設定します。
- password2 フィールドを使用した認証用ではありません
- setValue() メソッドは password2 データをクリアテキストとして渡すため、暗号化されたデータを予期する際にエラーが発生します。さらに、password2 フィールドに setValue() メソッドを使用すると、暗号化する必要があるデータが公開されます。
password2 認証の場合は、代わりに setDisplayValue() メソッドを使用してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| value | オブジェクト | フィールドを設定するオブジェクト値。 |
| タイプ | 説明 |
|---|---|
| なし |
文字列を渡す値を設定します。
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
glideRecord.short_description.setValue('Network failure');
オブジェクトを渡す値を設定します。
var now_GR = new GlideRecord('student');
now_GR.initialize();
now_GR.setValue('first_name', 'Joe');
now_GR.setValue('last_name', 'Smith');
now_GR.insert();
スコープ対象 GlideElement - toString()
GlideRecord フィールドの値を文字列に変換します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | 文字列としての値。 |
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority','1');
glideRecord.next();
gs.info(glideRecord.opened_at.toString());
出力:
2019-08-31 23:09:51