How to set value of a dynamic field?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Any one know how to set up value to a dynamic field. I have the function where field name would be sent as parameter and I do need to set value there.

Here is an example
function SetValue(params, Name){
$ = skuid.$;
var fieldName =params.model.getField(Name);
// var Mytext = do my task
if(params.model.getRowById(params.row.Id)[fieldName] !== skuid.$('.RichTextField).prop('innerHTML')){            

     params.model.updateRow(params.model.getRowById(params.row.Id),{ fieldName : 'Mytext'});
            skuid.$('.RichTextField div.nx-richtext-input').focus();
        }

}
Photo of Tanzir Riad

Tanzir Riad

  • 414 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I don't think you need to get the reference to the entire field object. You should be able to just use the field name

if(params.row[Name] !== skuid.$('.RichTextField').prop('innerHTML')){            

     params.model.updateRow(params.row, Name, 'Mytext');
            skuid.$('.RichTextField div.nx-richtext-input').focus();
        }
Photo of Tanzir Riad

Tanzir Riad

  • 414 Points 250 badge 2x thumb
Thanks Matt,
it works perfect...