画面のボタンからテーブルレコードのフィールド値を変更
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
06-14-2024 06:52 PM
お世話になっております。画面上にある廃止ボタンを押すことで、u_question_choiceテーブルレコードのinstall_statusのフィールド値をRetiredに、有効化ボタンを押すことでinstall_statusのフィールド値をInstalledにしたいです。ポータル画面上では、変更されたように見えましたがテーブルを見ると変更ができていなかったです。
コード面において、修正すべきところや不足しているところは何ですか?
HTML
<div>
<h3>Installed Items</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Value</th>
<th>Question</th>
<th>Order</th>
<th>Install Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in c.data.items | filter:{install_status:'Installed'}">
<td>{{item.u_value}}</td>
<td>{{item.u_question}}</td>
<td>{{item.u_order}}</td>
<td>{{item.install_status}}</td>
<td>
<button class="btn btn-danger btn-block" ng-click="retire(item)">廃止</button>
</td>
</tr>
</tbody>
</table>
<h3>Retired Items</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Value</th>
<th>Question</th>
<th>Order</th>
<th>Install Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in c.data.items | filter:{install_status:'Retired'}">
<td>{{item.u_value}}</td>
<td>{{item.u_question}}</td>
<td>{{item.u_order}}</td>
<td>{{item.install_status}}</td>
<td>
<button class="btn btn-success btn-block" ng-click="activate(item)">有効化</button>
</td>
</tr>
</tbody>
</table>
</div>
Serverscript
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
07-02-2024 06:06 AM
ClientScriptのspModal.open の引数が間違っていると思います。
Docsでは、spUtil - update(オブジェクト $scope) となっています。
spUtil - クライアント (servicenow.com)
Server side に Inputを渡したい場合、$scope.server.get( [Input Object] ) を使います。
ウィジェット API リファレンス (servicenow.com)
Server side Scriptでは、app.setValue('install_status', 'Retired' ); この'Retired'が間違っていると思います、標準では"7"を設定してRetiredにします。標準では install_status は 数字を設定する項目です。
このServer sideの処理にinput の op が activated の時の処理と、op が retired の時の処理がありません。今は固定で常にsetValueで固定値を設定しています。
op の値で 設定値を変えるべきかと思います。install_status には activated という設定はありません。Installed はあります、設定値は"1" です。
それと Server sideの inputの処理が、items.push より下にあるので、inputの処理で値を変更した物が、items に設定されないため、古い情報でListを表示してしまうと思います。 inputの処理を一番上に上げると良さそうです。