Skip to Main Content
Feature Request FR-4707
Product Area APIs
Status CLOSED

4 Voters

pSuppressChangeEvent parameter for method model.setValue()

mmulvaney Public
· Nov 7 2025

Idea Summary
apex.item.setValue() provides a parameter pSuppressChangeEvent to suppress the change event for the item being set

e.g.

apex.item( "P1_ITEM" ).setValue( "10", null, true );

However this parameter is missing from model.setValue()

setValue(pRecord_opt_, pFieldName, pValue) 

Use Case
The change event should be suppressed when the value is set while processing a change event triggered on the same column, to prevent an infinite loop.

Preferred Solution (Optional)
setValue(pRecord_opt_, pFieldName, pValue, pSuppressChangeEvent_opt_)

We reviewed this idea carefully, and while it was interesting, we concluded that due to all the internal implications we need to take into account, it is unlikely to make its way into APEX.

Comments

Comments

  • vincent morneau Admin OP 8 weeks ago

    Hi Matt, what is the issue you're trying to solve? apex.model should not trigger a change event in the first place.

  • mmulvaney OP 5 weeks ago

    Hi Vincent.

    apex.model.setValue 100% triggers a change event in another IG column.

    After some thought, I cannot think back to the use case that I was trying to solve. I can only think of this example with IG of columns:

    START_DATE, NUM_DAYS, and END_DATE

    Problem:

    1. User changes NUM_DAYS and a Change DA  (on NUM_DAYS ) recalculates the new END_DATE. 
    2. The Change DA (on END_DATE) automatically fires and tries to recalculates the new NUM_DAYS  
    3. Then the circle continues.

    Hope this helps

    MM

  • john.snyders APEX Team OP 4 weeks ago

    Hi Matt, Thanks for providing the use case.

    You are very certain so I checked very carefully. apex.model.setValue does not trigger a change event. It barely even knows about apex items (it has one place in calcValue that is undocumented where it will use item.getValue for page items not column items). The model code doesn't trigger any events (model data binding, which is independent of the model but in the same js file, does trigger one custom event and its not change). 

    It is possible that something subscribes to model notifications and turns a “set” notification into a change event but grid, and tableModelViewBase do not do that. So from code inspection there is no change event on model setValue. 

    Then I did a test using an editable IG region. I added an on change handler on a column item that just console logs. As a user I changed the value of the column and saw the change event log message. Then from the console I used the model setValue to change the column and saw that the grid UI was updated but there was no change event log message. This proving that there is no change event from model setValue.

    One place where the grid may trigger change event for a column item is in the copy down feature. The code has changed in this area so it could depend on what version of APEX you use. The intent is that when you copy values down a column that DAs on change should run. 

    For situations like you are describing I recommend using the model column calcValue function because it automatically handles breaking circular updates. The down side is that it is easier to call out to the server when using DAs. See https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/model.html#.FieldMeta

  • mmulvaney OP 4 weeks ago

    Hi @john.snyders 

    Based on my START_DATE, NUM_DAYS, and END_DATE example above… hopefully these screenshots will help.

    First, there is a change event on NUM_DAYS. So that when the user types in a value. It adds NUM_DAYS to START_DATE and sets END_DATE.

    var grid = apex.region("emp").widget().interactiveGrid("getViews", "grid");
    var model = grid.model;
    var rec = grid.getSelectedRecords()[0];
    
    var startDateStr = model.getValue(rec, "START_DATE");  // e.g. '10-FEB-2026'
    var numDays = Number(this.triggeringElement.value);    // e.g 12
    
    
    var p = startDateStr.split("-");
    var mon = {JAN:0,FEB:1,MAR:2,APR:3,MAY:4,JUN:5,JUL:6,AUG:7,SEP:8,OCT:9,NOV:10,DEC:11};
    var startDate = new Date(Number(p[2]), mon[p[1]], Number(p[0]));
    
    var endDate = apex.date.add(startDate, numDays, apex.date.UNIT.DAY);
    var endDateFormatted = apex.date.format(endDate, "DD-MON-YYYY");
    
    model.setValue(rec, "END_DATE", endDateFormatted);
    

    The IG END_DATE column has a change event on it which fires an alert

    Here it is in action. I enter the START_DATE, then END_DATE and then tab off.

    Therefore proving that: 

    apex.model.setValue 100% triggers a change event in another IG column.

    My OP was saying: model.setValue() needs a pSuppressChangeEvent parameter- just like apex.item().setValue has one.

    Hope this helps
    MM

  • karel ekema OP 4 weeks ago

    Allow me to add a remark which hopefully is clarifying:

    It is possible that something subscribes to model notifications and turns a “set” notification into a change event but grid, and tableModelViewBase do not do that. So from code inspection there is no change event on model setValue. 

    In case that model ‘set’ notification involves a record which is equal to the grid active record, it will trigger (indirectly via the model subscription in the view layer) a _setColumnItemValue() in widget.grid.js

    which will trigger the change event (widget.tableModelViewBase.js):

    I feel the solution for the given use case and given script is to use:

    apex.item('end_date_static_id').setValue(endDateFormatted, null, true); // pSuppressChangeEvent = true
    

    and then use grid.setActiveRecordValue()

    or alternatively resolve it fully on the model level using model column calcValue function John was referring to.

  • john.snyders APEX Team OP 4 weeks ago

    Thanks for the details Matt, I did look at your example but I was too busy today to reply again. Karel's answer is correct. It is an indirect change event. The model setValue is not triggering it. When the model changes the view stays in sync (see _updateRecordField) and this includes, when active for editing, setting the value in the page item. This issue has come up a few times on the forms for example: https://forums.oracle.com/ords/apexds/post/interactive-grid-column-not-refreshing-if-i-am-explicitly-d-4280

  • mmulvaney OP 4 weeks ago

    Hey @karel ekema @john.snyders 

    Many thanks for your explanations - it makes sense.

    You both provided workarounds which would be fantastic on a forum - however this is an idea on the APEX Ideas App.

    I believe my Idea still stands…

    My idea is to provide a pSuppressChangeEvent parameter for model.setValue()

    MM

  • john.snyders APEX Team OP 4 weeks ago

    Hi Matt, Fair point. You spent time making your case for why pSuppressChange should be added to model.setValue so you deserve an explanation for why the idea is closed.

    Because model doesn't and shouldn't know about items the only thing it can do is pass on that flag in the “set” notification and it would be up to the view layer (e.g. grid widget) to implement the desire to not trigger the change. There would be nothing to force the view to honor it. This makes it a fragile system. 

    Another thing that has been asked/suggested is why can item.setValue always update the model regardless of if the change event is suppressed.  Then you wouldn't need setActiveRecordValue. The reason is that we don't have control over how customers have implemented setValue in their item plug-ins. We already impose the need to trigger “change” even for programmatic updates because of DAs and LOV cascade. We did not want to impose another rule to follow (whatever it may be) so that model data is updated.

    We believe that tableModelViewBase setActiveRecordValue and model calcValue are sufficient ways to accomplish dynamic updates that may involve circular references. 

    Regards,