My Oracle Support Banner

VBCS - OnFieldValueChange Action Chain Is Breaking And Not Returning Value After Modifying Value - The expression ' $previous ' has a method that has mutated a variable (Doc ID 3001182.1)

Last updated on JANUARY 31, 2024

Applies to:

Oracle Fusion CX Sales Cloud Service - Version 11.13.23.10.0 and later
Information in this document applies to any platform.

Symptoms

On : 11.13.23.10.0 version, Opportunities

ACTUAL BEHAVIOR
---------------
OnFieldValueChange action chain is breaking and not returning value after modifying value

In childRevenue, the requirement is to apply a formula to different fields.
After applying the formula to the Quantity field (one of the filed that is touched by the formula) the action chain is breaking.
First, it populated fields from CX picker and then it needed to calculate value after modifying Quantity.

The error received was:
" Chain FormulaMPOpty failed. Error: The expression ' $previous ' has a method that has mutated a variable. This can lead to unexpected behavior when this expression is evaluated. Consider using the 'callModuleFunctionAction' instead for a safe way of mutating variables."

The code works when initially contains:

.............................

async run(context, { previous, event }) {
const { $layout, $extension, $responsive, $user } = context;
//My code start here
let row = JSON.parse(JSON.stringify(event.row));
if (event?.modifiedField == "EntryProductName_Id_c") {

row.ExtNetPrice_c = event.pickedRowsData["PriceEntry_c.EntryProductName_Id_c"].ListPrice_c;
row.ListPrice_c = event.pickedRowsData["PriceEntry_c.EntryProductName_Id_c"].ListPrice_c;
row.GrossPrice_c = event.pickedRowsData["PriceEntry_c.EntryProductName_Id_c"].ListPrice_c;
row.UnitPrice = event.pickedRowsData["PriceEntry_c.EntryProductName_Id_c"].ListPrice_c;
row.Quantity = "1";
//row.StandardDiscount_c = 0.2;
// row.Comments = Number(row.ExtNetPrice_c) * Number(row.Quantity);
//row.ExtNetPrice_c = Number(row.ExtNetPrice_c) * Number(row.Quantity);
previous = previous ?? {};
previous.row = row;
}

..............................

but it breaks with the above error when added:

if (event?.modifiedField == "Quantity") {
if (row?.ExtNetPrice_c != undefined && row?.Quantity != undefined) {
row.ExtNetPrice_c = row.ExtNetPrice_c * row.Quantity;
console.log("Extended Net price:" + row.ExtNetPrice_c);
}
previous = previous ?? {};
previous.row = row;
}

 

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.