Using Javascript snippet how to get data entered into field on popup

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Using javascript called via an action, how can I get the value(s) just entered by a user on a popup screen that is bound to a model?  The component on the popup is a "Field Editor" that contains fields from a model.  How can I access what a user entered into the fields using javascript?  I tried document.getElementById but it returns null. Thanks in advance for any help.
Photo of Glenn Shesney

Glenn Shesney

  • 230 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
You probably want to familiarize yourself with the skuid
Javascript API : https://www.youtube.com/watch?v=bU_m3bA1Bnk .
The basic syntax is as follows:

var model = skuid.model.getModel('Model_Name');
var row = model.getFirstRow();//or whatever row you want
var fieldValue = row.API_NAME__c;
Photo of Glenn Shesney

Glenn Shesney

  • 230 Points 100 badge 2x thumb
Thats fine and I can do that with data already in the model.  I'm looking for a way to interrogate the form and get the data for 1 or mode fields at the time to form is submitted using javascript.  This is data NOT yet saved to the model and is visible on the screen because it was entered by a user.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
OK, the model updates in real time. If the user made a change to a field, that change should be reflected in the model. You can check it out in the console to be sure.
Photo of Glenn Shesney

Glenn Shesney

  • 230 Points 100 badge 2x thumb
How does the model update in real time if I haven't clicked the save button which invokes "Save Model" action?
Photo of Glenn Shesney

Glenn Shesney

  • 230 Points 100 badge 2x thumb
I think I understand what your saying. The popup created a "New", "UnSaved" row which is bound to the model. using the API I should be able to get the data in the unsaved row in the model. Clicking save commits the temp row.  Is my understanding corrrect?
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Bingo!