Version: Istanbul
作るもの
ServiceNowでログイン直後に特定のURLにRedirectさせます
ここに書いてる内容をそのまま試しただけですが成功したので記事にして置きます
※リダイレクトの設定を入れた後に全セッションでログアウトしてから再ログインすると常にリダイレクトされて何も操作出来ないインスタンスになってしまう可能性がありますadmin権限でログイン済みのセッションを別ブラウザなどで保持しながら作業することをオススメします
System Porpertiesに値を追加
Filter Navigatorにsys_properties.listと入力しSystem Propertiesの一覧を表示して[New]ボタンを押下し、以下の値を追加します。
Suffix | Name | Type | Value | Description |
---|---|---|---|---|
glide.entry.first.page.script | glide.entry.first.page.script | string | new SPEntryPage().getFirstPageURL() | First page after authentication |
Script Includeを編集
Filter NavigatorにScript Includeと入力し、System Definition > Script Includesの一覧を表示します。一覧のNameにSPEntryと入力し、SPEntryPageを表示後、(i)アイコンかNameをクリックして編集画面に遷移します。
こうなっている箇所を
initialize: function() {
gs.addErrorMessage(user);
this.logVariables = false; // for debugging
this.portal = "/sp/"; // The URL suffix specified in the sp_portal record
},
こうします。
initialize: function() {
gs.addErrorMessage(user);
this.logVariables = false; // for debugging
//this.portal = "/sp/"; // The URL suffix specified in the sp_portal record
this.portal = "http://www.example.com";
},
これでRedirectの設定が出来ました。
ユーザ名を判定してRedirect先を変更する
やり方は色々あると思いますが、SPEntryPageの以下のfunction辺りで
getFirstPageURL: function() {
最後の方でこうなっている箇所とかを
this.logProperties('after', session);
if (!this.logVariables) {
gs.log('redirectURL: ' + redirectURL);
gs.log('User: ' + user.getName());
gs.log('is internal: ' + (!user.hasRoles()));
gs.log('returnUrl: ' + returnUrl);
}
return returnUrl;
こうとかします。
this.logProperties('after', session);
if (!this.logVariables) {
gs.log('redirectURL: ' + redirectURL);
gs.log('User: ' + user.getName());
gs.log('is internal: ' + (!user.hasRoles()));
gs.log('returnUrl: ' + returnUrl);
}
if (user.getName() == "usu")
return "https://ja.wikipedia.org/wiki/%E8%87%BC";
if (user.getName() == "kine")
return "https://ja.wikipedia.org/wiki/%E6%9D%B5";
return returnUrl;