私は製品と呼ばれるエンティティを持っています。商品価格というフィールドがあります。
現在、100個の製品を作成しています。すべての製品の「商品価格」フィールドを合計 (数学演算) し、「合計商品価格」という機会フィールドと呼ばれる別のエンティティに表示したいと考えています。
これに加えて、私が101製品を作成し、それが「商品価格」である場合、機会の「合計商品価格」フィールドは自動的に更新されます。
だから私はフォームのフィールドにSUMMEDを持っています。たとえば、フィールド A とフィールド B があり、フィールド A に 3.14 を掛けて、結果をフィールド B に表示します。
これがコードです。
function SumField() {
var price = Xrm.Page.getAttribute("new_price");
var total_price = Xrm.Page.getAttribute("new_total_price");
if(price.getValue() != null) {
var newValue = price.getValue() * 3.14;
total_price.setValue(newValue);
// Make sure the changes are saved back to the server - in CRM 4.0, this was crmForm.new_fieldname.ForceSubmit = true;
Xrm.Page.getAttribute("new_total_price").setSubmitMode("always");
}
}