Need help with the Skuid UI Only field

  • 2
  • Question
  • Updated 2 years ago
  • Answered
HI,

I have created a UI-Field in skuid 'Sample' and linked it with the salesforce field 'Sample__C'
its a checkbox field. I am trying to save the data using below JS and it is working.


var params = arguments[0],
$ = skuid.$;
console.log(params.model);
var mymodel=params.model;
var row=mymodel.getFirstRow();
var fieldMap = {};
mymodel.updateRow(row,'Sample__C',row.Sample);


But on the UI, when I check the 'Sample' field, save and refresh the page the field is Unchecked. can anyone suggest me how to resolve this issue.

Thanks in advance.
Photo of Linga

Linga

  • 228 Points 100 badge 2x thumb

Posted 2 years ago

  • 2
Photo of Henry Goddard

Henry Goddard

  • 776 Points 500 badge 2x thumb
At first glance, I notice that you've got a capital 'C' in 'Sample__C'. Custom fields are suffixed with a lowercase '__c'.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Linga,

If you're working with a UI-Only field, it would by definition not be linked to any Salesforce fields. That means its value can't be saved to Salesforce, and is going to start out unset every time your Skuid page loads. If you've also created a custom checkbox field in Salesforce though, you should be able to use that as you're hoping, if I'm understanding correctly. In case you haven't run across it already, here's our documentation on UI-only fields and models. That should help give some context on what the UI-only fields can be used for. 

-Mark
(Edited)
Photo of Linga

Linga

  • 228 Points 100 badge 2x thumb
Thank you for the immediate response.

Mark, 

I have already gone through the documentation, but couldn't find what I was expecting for. So what you are saying is that there is no way that the I can make the value to set whenever I reload the page, just like normal checkbox?
Photo of Matt Sones

Matt Sones, Champion

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

If you always want the box to be checked on pageload, you can do that with javascript (see below). If you want to save the value that was last entered before reload, you'll need to create a field in salesforce, not a ui-only field.


To make the field checked on pageload:

(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
var myModel = skuid.model.getModel('MyModelId'),
    row = myModel.getFirstRow();
myModel.updateRow(row,{'Sample' : true});
});
})(skuid);
Photo of Linga

Linga

  • 228 Points 100 badge 2x thumb
Hi Matt,

Thanks for the script, it works perfectly fine when the field is checked, saved and refreshed it works fine. But when I uncheck and save it, it still stays checked. Am I doing something wrong. Sorry if I sound dumb, I'm new to Skuid :(
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Another thought: if you want the ui-only field ('Sample') to always reflect the value of a database field ('Sample__c'), you could do that... but I'm not sure why you wouldn't just use the database field directly instead of trying to sync a ui-only field with the database field?
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
To build on Matt's thought, if there was a need to keep the data in your database field Sample__c protected, Skuid gives you a way to set it to read-only when you first pull it into your Skuid Model, by checking the box to "override metadata."
Photo of Linga

Linga

  • 228 Points 100 badge 2x thumb
Matt,

Thanks for the workaround.

I had to create a UI field due to Inline Help Text feature. In salesforce I can use only upto 255 characters for Inline help text, where as in skuid there is no limit for the UI field's help text, hence I had to follow this approach.

Can you help me with how to reflect the value of a database field on ui-only field, that would be helpful. Thanks.
(Edited)
Photo of Matt Sones

Matt Sones, Champion

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

Perhaps you can just use the 'override metadata' feature on the existing database field? Will that allow you to edit the help text?
Photo of Linga

Linga

  • 228 Points 100 badge 2x thumb
YESSS!!!!

That worked perfect! That was such a simple solution..
Thank u so much