UI only fields - rich text

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hi I want to add a rich text field as UI only field. I only see textarea as the closest type. How can I make it as rich text field as in Salesforce? If the field is from the object, Skuid renders it as rich text field properly.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
J,

Not sure what your use case is... could you use a rich text component instead?

You could create a textarea formula field, tie the rich text component to the model where your field is, drop in the fields with merge syntax, and format to your heart's content.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Thanks! I will need to put them next to other fields in the field editor. Reason is that I need to set value for existing rich text fields from another model with custom logic which looks for the most recent note field etc.. And as you commented on my other post, there is currently no way to call the custom rendered in js.
So I'm using two sets of fields to do this. The rich text field from Salesforce has the Skuid rich text controls, I want to do the same for my UI only fields. There seems to be only textarea type field. How do I apply the same control to them? Is there a way to attach the specific Skuid css?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
J,

Can you provide a more complete description of the desired use case? You're trying to display the most recent note with it's date?

Sounds like this could be a case for child fields on your parent model... unless I'm completely misunderstanding.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
It's the most recent non-empty note entered for the specific contact. So I cannot use the most recent one in the model order by createddate desc. I also need to dynamically set conditions if that lookup is entered by user. This is all working, but I need the UI fields to have the same look and feel as a standard salesforce rich text field in Salesforce.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I must still not be understanding.

Why the ui-only field? Can't you just use the field itself?
(Edited)
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
The field needs to be set based on the above conditions when user ticks a checkbox, not on page load. And user can continue to edit it and do other things and save the record.
(Edited)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
J,

Seems you need to use a model to set the conditions for the field (action framework activated by an update to your checkbox field). The model conditions should return the one field that you want on query. Then use the field itself (with a custom renderer, if needed).

No need to save the model until you want to.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Yes I'm using conditions. Unfortunately, rich text fields cannot be used as conditions. And custom renderer only triggers on page load, not on checkbox right? I can't use update the fields via an action either but I don't know which row of the model I end up using to set the field. It might be the first record, or next record.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
So is there a way to style the text area UI fields as rich text field without editing controls?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
J.  The answer is no.  You can't make a UI only field with rich text controls. 
But I think Matt is on to the better solution....
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
J

Rendering logic will run every time the field is rendered (on pageload, or when conditional rendering conditions are met, or when the model is queried/updated).

You probably need a separate model just for your the rich text field.
If you need to, you can create a boolean field in your object called "NotesExist__c" or something like that. Then make workflow rules to run anytime the record is saved to update the value of the NotesExist__c to true if it's not blank, or false if it is blank. Then you can build conditions on your model(s) and query based on that field.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Sorry for the confusion on this. I don't have the options to create
a new field on the custom object to support this.

This is supposed to be a very simple task in Salesforce.
So on a new record create page for contact_result__c,
I have a UI only checkbox , 3 notes rich field and other lookups etc from the salesforce object.
When checkbox is ticked, I want to set these 3 notes field from the
latest contact_result__c for the specified contact/opportunity
/candidate/engagement that has the note1 or note2 or note3 field
populated. So it could be that the latest record has note1 field
populated, the one before that has note2 populated and the one
before that one has note3 field populated.
So I would need to look at all the historical records,
and set the 3 notes fields on the new record page from 3 or more
historical record. In Apex, this can be done in 5 minutes.

Here is what I tried in Skuid:

1. Model_1 for new contact_result__c
2. Model_2 for all contact_result__c, order by createddate desc
inactive conditions for opportunity__c = opportunity__c on Model 1
...

Action on Model_1:
Row in Model updated, when checkbox field is updated
Action: update a field on Row
Value: -- Model_2.data.0.note1field
This does not work since I don't know the index of the record.

Dynamic renderer on 3 notes fields
set value if checkbox is on
Code works. But it won't work since the checkbox is never on when page loads.

Custom button on Model_1
set value if checkbox is on

Code works, but there is no value changes on the UI. The error in the console says
there is unsaved data on the new contact_result__c record.
So I added these two lines:
MyContactResult.save();
MyContactResult.updateData();

However, by doing this, the UI now has 12 new contact_result__c records displayed

Besides, in reality, I don't want to commit any work unless user clicks on
Save. And I don't want to ask user to click on the button to turn on or off
the features. That's just not intuitive.

Considering the limitations here, I added 3 UI only fields for the 3 notes
fields, so that the custom renderer would work on the 3 original rich text fields.
That works perfectly, but the UI only fields are text area witout CKEditor controls.
I cannot give that to the users?

Please help!
(Edited)
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Dynamic renderer approach worked. And set the htmlFormatted attribute for the field to true will render the text area ui field with the CKEditor controls.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Glad you got this working.  I still think you may have chosen a more complicated path than necessary, but you are in the clear - so who's checking now...