You need to sign in to do that
Don't have an account?
RemoteObject Javascript
Hello, I would know in my code how can I get the name of the user who edited the post. I can get ID from the User that modified the post, but I want to get the name.
<!-- Remote Objects definition to set accessible sObjects and fields -->
<apex:remoteObjects >
<apex:remoteObjectModel name="Post__c" jsShorthand="Post" fields="Name,Id,LastModifiedDate, LastModifiedById">
<apex:remoteObjectField name="Body__c" jsShorthand="Body"/>
<apex:remoteObjectField name="Tags__c" jsShorthand="Tags"/>
</apex:remoteObjectModel>
</apex:remoteObjects>
<div id="rows"> </div>
<script>
// Create a new Remote Object
var pt = new SObjectModel.Post();
// Use the Remote Object to query for 3 post records
pt.retrieve({ limit: 3 }, function(err, records){
if(err) alert(err.message);
else {
var rows = document.getElementById("rows");
var ptLastModifiedById = record.get("LastModifiedById");
//div data
var postData = document.createElement('div');
postData.className = "postData";
postData.innerHTML += ptLastModifiedDate + " by " + ptLastModifiedById;
div.appendChild(postData);
rows.appendChild(div);
});
}
});
</script>
There are two approaches you can able to solve this problem
All Answers
There are two approaches you can able to solve this problem