0

I’m currently having trouble setting an item upon page load. It seems that the value is being stored only on the client side, not on the server side.

While the current behavior works properly when checked in the console, the item is not set during the initial load of the Interactive Grid. The page needs to be re-submitted before the value is actually stored in the item.

Here's my sample code below.

 "IG1", "IG2", "IG3", "IG4", "IG5", "IG6" ]; var found = false; // Loop through grid IDs to find the visible one for (var i = 0; i < gridIds.length; i++) { var regionId = gridIds[i]; var region = apex.region(regionId); // Check if region exists and is visible if (region && region.widget().is(":visible")) { var ig$ = region.widget(); var model = ig$.interactiveGrid("getViews", "grid").model; var fieldKey = model.getFieldKey("STATUS"); model.forEach(function(record) { var value = record[fieldKey]; console.log("Field value:", value); if (value === 'ERROR') { found = true; apex.item("P1_ERROR_FLAG").setValue("ERROR"); return false; // break loop } else if (value === 'WARN') { found = true; apex.item("P1_WARN_FLAG").setValue("WARN"); return false; // break loop } }); break; // exit loop after handling the visible grid } } console.log("Value exists:", found);``` 

2 Answers 2

0

That is the expected behaviour. The line apex.item("P1_ERROR_FLAG").setValue("ERROR"); sets the value of the page item on the client side. Observe the network tab in the browser console - there will not be communication with the server when this happens. The value gets sent to the client in any of the following cases:

  • Page submit (as you noticed)
  • Page item is set as "Items to submit" in Dynamic action of type serverside code or in a report.
  • When it is passed as an argument in an apex.server.process call.

The post does not say when this code executes but I would create a dynamic action on change of P1_ERROR_FLAG that has an action of execute serverside code, items to submit set to P1_ERROR_FLAG and code NULL;. This will submit that page item to the server.

There might be better solutions for your use case but then please provide more info (as much as possible ) about how the page is set up: at what point do you need the P1_ERROR_FLAG value and how is it used ?

Sign up to request clarification or add additional context in comments.

Comments

0

Submit Items to Session State (Simpler)

If you just need to refresh a region or re-run a computation that depends on those items, call:

apex.server.process(null, { pageItems: "#P1_ERROR_FLAG,#P1_WARN_FLAG" }); 

This doesn’t need a PL/SQL process name; it just synchronizes session state for those page items.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.