Service Portal でカタログアイテムの添付ファイルを必須にする方法Issue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } UI スクリプトと onSubmit カタログクライアントスクリプトを使用して、Service Portal でカタログアイテムの添付ファイルを必須にする方法について説明します。 ServiceNow では、Service Portal のカタログアイテムに対して添付ファイルを必須にするデフォルトのオプションは提供されていません。ただし、カスタム UI スクリプト、onSubmit カタログクライアントスクリプト、および Service Portal テーマの JS include を作成することで、これを実現できます。 Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } サポートされているすべてのリリース Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } ステップ 1: UI スクリプトを作成する 以下の詳細で UI スクリプトを作成します。 API Name: GlobalCatalogItemFunctionsUI Type: AllActive: trueScript: function getSCAttachmentCount() { var length; try { length = angular.element("#sc_cat_item").scope().attachments.length; } catch(e) { length = -1; } return length;} ステップ 2: onSubmit カタログクライアントスクリプトを作成する 以下の詳細で onSubmit カタログクライアントスクリプトを作成します。 Name: make attachment mandatoryApplies to: A Catalog ItemActive: trueUI type: AllType: onSubmitCatalog Item: 必要なカタログアイテムを設定します。Applies on Catalog Item view: trueScript: function onSubmit() { //Type appropriate comment here, and begin script below try { //Works in non-portal ui var attachments = document.getElementById('header_attachment_list_label'); if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) { alert('You must attach the completed form before submitting this request.'); return false; } } catch(e) { //For Service Portal var count = getSCAttachmentCount(); if(count <= 0) { alert('You must attach the completed form before submitting this request.'); return false; } }} ステップ 3: Service Portal テーマに JS include を設定する [Service Portal] > [Portals] に移動します。URL suffix = sp でフィルタリングします。ポータルレコードを開きます。ポータルレコードからテーマレコードを開きます。テーマレコードで、JS Includes 関連リストに移動し、[New] を選択します。Display name を attachment validation に設定します。Source を UI Script に設定します。UI Script フィールドで、GlobalCatalogItemFunctions (ステップ 1 で作成したもの) を選択します。 警告: このソリューションはコミュニティによるカスタマイズであり、ServiceNow サポートの対象範囲外です。 Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Creating and managing UI scripts Get started with Service Portal