Formula field not refreshing

  • 1
  • Problem
  • Updated 4 days ago
  • In Progress
I have an issue where ui only filed on table in skuid is not changing the values in the field in Salesforce. Also the module does not seem to filter as we wanted only active status records but it gets all. I changed the formula in Salesforce but the data still reflects old value in skuid. Not sure what needs to be done.
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb

Posted 3 weeks ago

  • 1
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,426 Points 10k badge 2x thumb
Hi Gopal,

It sounds like you're using a UI-only field inside a Skuid page. Please note that these fields are not connected to any fields in Salesforce objects. They're meant for temporary information, and as a way to create more complex UI-related logic. So, a UI-only field's data will never directly be saved to a Salesforce field. There's lots of information available in our documentation about UI-only fields & models - here's a good place to start.
https://docs.skuid.com/latest/en/skuid/models/ui-only-models-fields.html#ui-only-models-and-fields

Regarding your issue with the status filter, we'll need more details to understand how you have this configured. Perhaps you can share screenshots, or a simple Skuid page that reproduces the setup?

I would highly recommend reviewing this documentation about filters too, to ensure that your Status filter is set up correctly.
https://docs.skuid.com/latest/en/skuid/filters/#filters
https://docs.skuid.com/latest/en/skuid/filters/select-option.html#filter-a-table-from-a-list-of-opti...
https://docs.skuid.com/latest/en/skuid/filters/table-filter.html#create-a-filterable-table
https://docs.skuid.com/latest/en/skuid/filters/multi-select.html
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
Mark,
I have a Model lookup for the field. it is showing old values even though values in salesforce filed is chaged
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
This is a model with conditions. condition is to pick records whose status is active. but it it getting records not active also. 
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
here is the setup.
I have a table  with model 
and other other models on the page as well.
Table filed editor has a UI only field with formula. This filed in the model as Table is.
Formula is Model look up and reference model has condition and aggregates and groupings. one of the condition is status contains Active or Hold. But it is also bringing cancle status records as the value in the look up is belongs to a cancel record. I am doing  MIN on a field as an aggregation. 
As it was not filtering I changed the formula field in salesforce but in SKUID it is still showing the old values not refreshing.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,426 Points 10k badge 2x thumb
Hi Gopal,

Formula fields actually do not update in all situations. If your formula field isn't updating when your use case needs it to, you can use a snippet to run 'skuid.$M('yourmodel').evaluateFormulas()' to ensure the formulas are reevaluated. If you do this, you may also need to re-render any components that are showing this formula field's output - a command for that is this: 'skuid.components.getById('someComponent').render().'  

You may also be able to reevaluate the formula just by re-querying the model, or updating a field on the model, but that option isn't useful in every situation. One way I've seen is to set up a model action on the reference model that queries the second model (the one with the formula). You can trigger the model action whenever the key fields have changed. This would be the best option if it fits your use case. Let me know if I can clarify any of this.

I'm not sure I understand the setup that's involved in your status issue, but it sounds like the aggregation or its conditions may not be set up properly. If you could share any screenshots or XML for a simple repro page (with standard objects) that would be helpful. 
Photo of Louis Skelton

Louis Skelton

  • 4,970 Points 4k badge 2x thumb
Hey Mark, just an aside on this - I've noticed that evaluateFormulas() doesn't seem to be called when a model is updated via the "Auto-sync with other Lightning Components" setting on the Model. It'd be cool if it did! That said, I didn't know .evaluateFormulas() was a thing - cool! Cheers!
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
I changed render conditon for UI only field. New values showed up . But when I change the condition on Aggreate model values are not changing i.e Model is not requerying. I Used your skuid.$M('yourmodel').evaluateFormulas() in the model inline snippet but nothing has changed I am sure I am doing something wrong. I am surprised that it does not change even if condition changes
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
not heard from you .please update on what needs to be done. 
skuid.$M('ModelName').evaluateFormulas();
skuid.components.getById('sk-eIZji-499').render();

added them in a inline snippet. no changes
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
You can suggest where is the best/proper place to use other than inline snippet. so that I can try that . Those two statements where should be to execute and see the refresh data 
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
If I am not explaining properly please let me know. As I would expect that should work seamlessly without any issues but it seems to be needing some work around. 
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
You suggested
" you can use a snippet to run 'skuid.$M('yourmodel').evaluateFormulas()' to ensure the formulas are reevaluated." so I added in a snippet
Photo of gopal

gopal

  • 160 Points 100 badge 2x thumb
Just to let you know we are on 9.5.4 if it makes any difference
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,284 Points 10k badge 2x thumb
Hi Gopal. If you've added a snippet with those bits of code, and replaced 'yourmodel' with the name of your model, then what you'd need to do is add a model action to the source model that triggers the snippet when your source field has changed. By 'source model' and 'source field,' I mean the model and field that holds the values your model lookup is looking to. Does that make sense?