How to update a field

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a UI only checkbox on the model which is a new record A page. When that's checked I want to set up notes field 1, 2 and 3 from another model which is a list of records A if that's the last notes field with a value. I'm trying to make this work using the action on new record model via the params.updates on the checkbox. In the snippet, I make a remote action call to Salesforce since list of records A is used for display now and cannot be modified to handle the complexity of selecting the right notes field. The remote call works, but I cannot seem to call updateData() on the model without saving it first. I don't want to save the model yet since user will need to fill out other data and might use this checkbox at any point before saving the record. Any suggestions on how to update the fields in the UI only without saving the model?
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Would something like this work: skuid.ui.fieldRenderers.TEXTAREA.edit(row.notes__c, 'test notes') ;
Photo of KVin

KVin

  • 1,158 Points 1k badge 2x thumb
Hello J,

Try like:

In the field render snippet :
var field = arguments[0],    
value = arguments[1], 
$ = skuid.$;

//Modify field-value to something you need based on your condition

if(your condition = TRUE)
{
value = 'new Value' ; //New Value 
}
else
{
value = value;   //Keep it as it is.
}

//Render the field to UI
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
(Edited)
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Hi thanks. This works if I put this on the note field itself. How do I put this on the model action so that when the checkbox is ticked, I can set the value in the note field. So essentially I need to do this dynamically like this:
skuid.ui.fieldRenderers["TEXTAREA"]["edit"](row.fieldname,'value');

This is not working. Error says Unable to get property 'options' of undefined or null reference
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
So how do I call custom rendered on a field dynamically on the model action when there is a change in another field?
Photo of Matt Sones

Matt Sones, Champion

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

I don't think you can force a field to render in a model action.

Instead, you could put two versions of your field on the page, one with your field renderer and one without, and then conditionally render them based on the value of your checkbox.