I have a table displaying multiple rows from a custom object.
The edit action is a popup which displays the selected row in a field editor.
The popup also has a page title component with a Save button.
The page title and the field editor both reference the same model.
The first Save action is to run a javascript snippet.
How can that snippet determine which row is the active one on the popup?
The snippet is passed an argument, “argumentst0]”, which is an object.
Developer Tools console displays the object as:
Object
component: p
context: Object
editor: c
initiatorId: 63
model: W
row: Object
proto: Object
The context, model, and row nodes can be expanded. For example, row opens up as:
row: Object
CreatedBy:ObjectCreatedById:“005t0000000HfckAAC”
CreatedDate:“2016-08-18T22:34:18.000+0000”
Crush__c:true
Frequency__c:“1”
Id:“a1fr00000004SszAAE”
Id15:“a1fr00000004Ssz”
<etc.>
However, in spite of the fact that the popup was displaying and editing the second row from the table, the row object from the argument is the content of the first row from the table.
And although the “context” object might be expected to provide context, it does not. It also has model and row objects, but they only provide another instance of the same data from the first row of the table.
The model node does provide some help. It can be expanded to show a “changes” object, and this object is the context row that is being edited:
model: W
…
changes: Object
a1fr00000004M0DAAU:Object
Frequency__c:“2”
…
And my use case does in fact need me to compare “changes” to “originals” (which is also found in the model node):
model: W
…
originals: Object
a1fr00000004M0DAAU:Object
Frequency__c:“1”
…
My question is how do I obtain that M0DAAU Id as a javascript value?
I can assign var modStruct=argumentsu0].model, which is the object W.
And I can assign var frequency=modStruct.originals.a1fr00000004M0DAAU.Frequency__c, which is the value 1.
But arguments<0].model.originals is an object, and argumentst0].model.originalsl0] is undefined.
And argumentsg0].model.originals.Frequency__c is also undefined.
I am not seeing a way to assign that context Id to a javascript variable so I can do this:
var theId = ???;
if ( modStruct.changes.theId.Frequency__c > modStruct.originals.theId.Frequency__c ) {…}