Ui-only reference field not saving the value in the UI only field

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have a UI-only field that is a reference field. The lookup works fine. When I save the record and refresh the page the information in the UI-only field is no longer there. What am I missing to ensure the data saves properly?
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I don't think UI only Fields save any info to a database. You would have to use regular Salesforce fields to store data so that it would appear on next page load.
Photo of Peter Kong

Peter Kong, Employee

  • 440 Points 250 badge 2x thumb
Raymond is correct! UI-Only fields are client-side only and contained within the Page it's on, so any information contained in UI-Only fields will not be saved back to Salesforce.
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Thank you for the clarification. I didn't think the Ui-Only field would save back to SF, I thought it would just be saved client side. I am curious what would a scenario be when using the reference ui-only field?
Photo of Peter Kong

Peter Kong, Employee

  • 440 Points 250 badge 2x thumb
Tami, I recently came across a good use case that's been tested and true (albeit more complicated)! Without explaining way too much....

Let's say I want a single filter on the top of a Page that filters the Contacts field on multiple Models; I'd use a UI-Only Reference Field from a Contacts Object on a dummy Model (Model that's not using any real data from the Object it's referencing). The reasoning is primarily:
  1. I don't know what all my valid Contacts are otherwise.
  2. I don't really need to save this data, I just need a Picklist of References (that could also be AutoComplete) that are valid. 
I can explain this more in-depth if you are curious, but that's the gist of one use-case :) 
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Peter,

Thank you for this use case. I am trying to do something similar but have not been totally successful yet. 


1.I am using a Ui-only Reference field to look up to my Item object.
2. Based on the item that is displayed another model will show all the invoices that have that item. There is a condition that looks to the ui-only field. 

So far I have not been able to just show invoices that have the selected item.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I believe UI only fields can be used in model conditions. perhaps you might want a user to select a contact and then activate a model condition that uses the contact Id to pull up all tasks related to that contact in repeating field editors instead of a table???? I'm sure someone will think of some reason to need it! UI also allows you to perform actions and calculate formulas in real time without needing to save to the database. You could theoretically create a proposal that uses formulas on your data in real time and then decide if you want to commit it to the database. Perhaps you are negotiating in the phone and you are not sure if the customer wants to buy or what the exact terms would be or which service he will choose from the related look up field so you don't want to commit to the database just to update the total price times a 15% discount broken into monthly payments. I believe you could accomplish this all with UI fields and then commit to the database using actions of the customer decides to move forward. Last thing I can think of is that perhaps you have a third party rest service that stores raw data that you then want to do math on and commit the result to the Salesforce database as opposed to storing all the raw data In Salesforce and doing the math in Salesforce. You might need to reference related records in the third party and/or salesforce database to do your math. I haven't used them much so exercise caution in taking my word for it!