I am using code that someone else worked on. From the code, I can tell it is smart enough to recognize that the record it is processing is the current record for the lightning component. How can I then modify the name to explicitly say that for my users?
if(so.get('id') == currentRecordId
seems to be the key part. so.get('name')
also seems to work. How can I change the value in so.get('name')
?
This is the apex controller:
//Run query and store results
List<sObject> queryOutput = new List<sObject>();
queryOutput = database.query(finalQueryString);
//Loop through the values
Integer level = 0;
for(sObject so: queryOutput){
HierarchyData ss = new HierarchyData();
if(so.get('id') == currentRecordId /*|| level == 0*/){
ss.expanded = true;
//This next line is where I am trying to modify the name.
so.put(so.get('name'), so.get('name')+': Current Record');
}else{
ss.expanded = false;
}
ss.rec = so;
returnValue.add(ss);
level++;
}
//return values to the component
system.debug('**********returnValue:'+returnValue);
return returnValue;
}
//Wrapper class
public class HierarchyData{
@AuraEnabled
public sObject rec{get;set;}
@AuraEnabled
public boolean expanded{get;set;}
public HierarchyData(){
expanded = false;
}
}
The top part of the code is just defining the variable finalQueryString, which works as expected.
so.put('Name', 'Some Value');
and that works. What do you recommend?lightning:tree
) tree demo you can look at here. I dunno if it'll help, but there you go.