Fg

Okay, let's look at the screenshots. Analysis: Functions.js - getUaRiskProfileChoices (IMG_0832.jpg, IMG_0837.jpg, IMG_0838.jpg): These screenshots show the definition of functions.getUaRiskProfileChoices. It correctly determines the base list of choices based on PEF, account program, risk matching (uaRiskProfileMatchingRiskProfile), or all profiles (allUaRiskProfiles). HOWEVER, the critical FHSA adjustment logic we discussed (the if (isFHSA) block that creates finalChoices with +1 keys) is missing from the end of this function in these screenshots. The function shown ends with return choices; (line 75367), which returns the unadjusted, base key list. Functions.js - allUaRiskProfiles (IMG_0843.jpg, IMG_0845.jpg): This helper function correctly defines the base list of all possible profiles (keys "10" through "90"). This is expected. ProductModelHelpers.js - Debugger (IMG_0846.jpg): This is crucial. It shows the code inside autoSelectUaRiskProfileForSingleOption. It calls functions.getUaRiskProfileChoices (line 79560). The debugger watch for uaRiskProfileOptions shows an Array[8] containing objects with base keys: {key: "40", ...}, {key: "50", ...} etc. This confirms that the getUaRiskProfileChoices function, as it's being executed in this flow, is returning the original 8 base choices, not the adjusted FHSA choices. FieldEnums.js (?) - UARiskProfile / uaRiskProfileChoices (IMG_0847.jpg): This seems to show static definitions or constants. It shows both the base ("GROWTH": "70") and potentially pre-calculated adjusted maps ("key": "71", value: "...GROWTH"}). While these adjusted definitions might exist statically, the getUaRiskProfileChoices function isn't actually using the adjusted ones when planType is '18' based on the debugger output. Conclusion & Fix: The problem is exactly what the debugger shows: The functions.getUaRiskProfileChoices implementation being run does not contain the FHSA key adjustment logic. You need to add the if (isFHSA) block to modify the choices before returning them. Required Code Change (Top Priority): Go back to Functions.js, find the functions.getUaRiskProfileChoices function definition (starts around line 75341). Insert the following code block IMMEDIATELY BEFORE the final return choices; line (around line 75367): // ========================================================== // ===== INSERT FHSA ADJUSTMENT LOGIC HERE ================== // ========================================================== var finalChoices = []; // Create a new list to return // Get the product object passed into this function // Ensure 'product' variable holds the correct context here var isFHSA = product && product.get(ddField.Product.planType.id) === '18'; if (isFHSA) { // If FHSA, create ADJUSTED choices from the 'choices' list determined above for (var i = 0; i < choices.length; i++) { var baseChoice = choices[i]; // Attempt to parse the key as integer var baseKeyInt = parseInt(baseChoice.key, 10); // Check if it's a standard numeric key (10-90) eligible for adjustment if (!isNaN(baseKeyInt) && baseKeyInt >= 10 && baseKeyInt

Apr 10, 2025 - 01:14
 0
Fg

Okay, let's look at the screenshots.

Analysis:

Functions.js - getUaRiskProfileChoices (IMG_0832.jpg, IMG_0837.jpg, IMG_0838.jpg): These screenshots show the definition of functions.getUaRiskProfileChoices. It correctly determines the base list of choices based on PEF, account program, risk matching (uaRiskProfileMatchingRiskProfile), or all profiles (allUaRiskProfiles). HOWEVER, the critical FHSA adjustment logic we discussed (the if (isFHSA) block that creates finalChoices with +1 keys) is missing from the end of this function in these screenshots. The function shown ends with return choices; (line 75367), which returns the unadjusted, base key list.
Functions.js - allUaRiskProfiles (IMG_0843.jpg, IMG_0845.jpg): This helper function correctly defines the base list of all possible profiles (keys "10" through "90"). This is expected.
ProductModelHelpers.js - Debugger (IMG_0846.jpg): This is crucial.
It shows the code inside autoSelectUaRiskProfileForSingleOption.
It calls functions.getUaRiskProfileChoices (line 79560).
The debugger watch for uaRiskProfileOptions shows an Array[8] containing objects with base keys: {key: "40", ...}, {key: "50", ...} etc.
This confirms that the getUaRiskProfileChoices function, as it's being executed in this flow, is returning the original 8 base choices, not the adjusted FHSA choices.
FieldEnums.js (?) - UARiskProfile / uaRiskProfileChoices (IMG_0847.jpg): This seems to show static definitions or constants. It shows both the base ("GROWTH": "70") and potentially pre-calculated adjusted maps ("key": "71", value: "...GROWTH"}). While these adjusted definitions might exist statically, the getUaRiskProfileChoices function isn't actually using the adjusted ones when planType is '18' based on the debugger output.
Conclusion & Fix:

The problem is exactly what the debugger shows: The functions.getUaRiskProfileChoices implementation being run does not contain the FHSA key adjustment logic. You need to add the if (isFHSA) block to modify the choices before returning them.

Required Code Change (Top Priority):

Go back to Functions.js, find the functions.getUaRiskProfileChoices function definition (starts around line 75341).

Insert the following code block IMMEDIATELY BEFORE the final return choices; line (around line 75367):

// ==========================================================
        // ===== INSERT FHSA ADJUSTMENT LOGIC HERE ==================
        // ==========================================================
        var finalChoices = []; // Create a new list to return
        // Get the product object passed into this function
        // Ensure 'product' variable holds the correct context here
        var isFHSA = product && product.get(ddField.Product.planType.id) === '18';

        if (isFHSA) {
            // If FHSA, create ADJUSTED choices from the 'choices' list determined above
            for (var i = 0; i < choices.length; i++) {
                var baseChoice = choices[i];
                // Attempt to parse the key as integer
                var baseKeyInt = parseInt(baseChoice.key, 10);

                // Check if it's a standard numeric key (10-90) eligible for adjustment
                if (!isNaN(baseKeyInt) && baseKeyInt >= 10 && baseKeyInt <= 90 && baseKeyInt % 10 === 0) {
                    var adjustedKey = (baseKeyInt + 1).toString();
                    finalChoices.push({ key: adjustedKey, value: baseChoice.value }); // Use ADJUSTED key + Original display value identifier
                } else {
                    // Keep non-standard keys (like maybe PEF '90' if it shouldn't adjust?)
                    // Or potentially already adjusted keys if logic gets messy.
                    // For now, just push the original if not a standard base key.
                    // Revisit PEF '90' -> '91' logic specifically if needed. Assume '90' adjusts for now.
                     if (baseKeyInt === 90) { // Specifically handle PEF 90 -> 91 case
                         finalChoices.push({ key: "91", value: baseChoice.value });
                     } else {
                         finalChoices.push(baseChoice); // Push other non-standard keys unmodified
                     }
                }
            }
            // Return the NEW list with adjusted keys
            return finalChoices; // ***** IMPORTANT: Return the new list *****

        } else {
            // Not FHSA, return the original base choices list calculated above
             return choices; // ***** IMPORTANT: Return the original list *****
        }
        // ==========================================================
        // ===== END OF INSERTED LOGIC ==============================
        // ==========================================================

        // The original 'return choices;' line below this block should now be effectively replaced
        // return choices; // <--- Make sure the logic above returns INSTEAD of reaching this line.
content_copy
download
Use code with caution.
JavaScript
Next Steps:

Implement: Add this exact block inside functions.getUaRiskProfileChoices right before it would normally return. Make sure the function now returns finalChoices if FHSA, or choices if not.
Save & Deploy/Refresh: Ensure the change is saved and the application picks up the updated Functions.js. Clear browser cache if necessary.
Test:
Select FHSA (planType '18').
Open the uaRiskProfile dropdown. It should now display the correct names (e.g., "Growth").
Select an option ("Growth"). The model should be set to the adjusted value ("71").
Select the same option again ("Growth"). The model should remain "71".
Check the Review page - the value ("71") and the display name ("Growth") should persist.
Use the debugger again on uaRiskProfileOptions inside the helper function - it should now show the adjusted keys (11, 21, ... 91) when planType is '18'.
This directly addresses why the UI wasn't getting the right options and should fix the display name and re-selection issues (Problems 1 & 3). Once this works, we can double-check the plan type switching logic (Problem 2) using the refined _adjustRiskProfileFHSA helper.