Need help with the Skuid UI Only field

edited February 4, 2020 in Questions
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.


Comments

  • edited January 9, 2017
    At first glance, I notice that you've got a capital 'C' in 'Sample__C'. Custom fields are suffixed with a lowercase '__c'.
  • Mark DeSimoneMark DeSimone 🛠️ 
    edited February 4, 2020
    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 January 11, 2017
    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?
  • Matt SonesMatt Sones 💎💎💎
    edited February 10, 2017
    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);
  • Matt SonesMatt Sones 💎💎💎
    edited February 4, 2020
    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?
  • Mark DeSimoneMark DeSimone 🛠️ 
    edited January 10, 2017
    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."
  • edited January 9, 2017
    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 January 10, 2017
    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 :(
  • Matt SonesMatt Sones 💎💎💎
    edited January 10, 2017
    Linga,

    Perhaps you can just use the 'override metadata' feature on the existing database field? Will that allow you to edit the help text?
  • edited January 10, 2017
    YESSS!!!!

    That worked perfect! That was such a simple solution..
    Thank u so much
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!