sn_sc.CartJS() から addToCart() 関数を使用して、複数のアイテムをカートに追加する方法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: ; } } この記事では、 addToCart() 関数を使用して、現在のユーザーのカートに複数のアイテムを追加する方法について説明します。 sn_sc.CartJS() を呼び出すために期待どおりに機能しています。を複数回して、複数のアイテムを追加できるようにします。 手順 初期設定のインスタンスにシステムアドミニストレーター (または admin ロールを持つユーザー) としてログインします。システム定義>スクリプト - バックグラウンドに移動します。そして、次のスクリプトをテストします。 //************************************************************ var cart = new sn_sc.CartJS(); for (i = 0; i < 2; i++) { gs.addInfoMessage('i: '+ i); var item = { 'sysparm_id': '10a2f5dfc6112276018db58138c7a1e0', //sys_id of catalog item 'sysparm_quantity': '1', 'variables': { }, }; cart.addToCart(item); } //************************************************************ ユーザーのカートには 2 つのアイテムが追加されることを想定していますが、現在のユーザーの sc_cart レコードを確認すると、1 つのアイテムしか追加されていません。 (現在のユーザーの sc_cart レコードを検索するには、インスタンスメニューのフィルターナビゲーターに「 sc_cart.list と入力します。User 列) で結果のリストをフィルタリングします。 現在のユーザーの sc_cart レコードをすべて削除します。システム定義>スクリプト - バックグラウンドで次のスクリプトを再度テストします。 //************************************************************ for (i = 0; i < 2; i++) { gs.addInfoMessage('i: '+ i); var cart = new sn_sc.CartJS(); var item = { 'sysparm_id': '10a2f5dfc6112276018db58138c7a1e0', 'sysparm_quantity': '1', 'variables': { }, }; cart.addToCart(item); } //************************************************************ 注 "var cart = new sn_sc.CartJS();」がループ内にあります。このスクリプトは、2 つのアイテムをカートに追加します。 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: ; } } London, Orlando 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: ; } } 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: ; } } CartJS (開発者向けドキュメント)