Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Created September 6, 2014 13:43
Show Gist options
  • Save tyoshikawa1106/653543e9d15cc0727ed7 to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/653543e9d15cc0727ed7 to your computer and use it in GitHub Desktop.
<apex:page standardController="Account" showHeader="true" sidebar="false" id="page">
<apex:include pageName="RemoteObjectsUpsertRemote" />
<div id="vf-page">
<apex:form id="form">
<apex:inputText value="{!Account.Name}" id="accountName"/>
<apex:commandButton value="Upsert" onclick="return upsertAccount('{!Account.Id}', '{!$Component.accountName}');" />
</apex:form>
</div>
<apex:include pageName="RemoteObjectsUpsertScript" />
</apex:page>
<apex:page >
<apex:remoteObjects >
<apex:remoteObjectModel name="Account" fields="Id" />
</apex:remoteObjects>
</apex:page>
<apex:page >
<script type="text/javascript">
function upsertAccount(prmAccountId, prmAccontName) {
var accountName = document.getElementById(prmAccontName).value;
var account = new SObjectModel.Account();
if (prmAccountId) {
account.set('Id', prmAccountId);
}
account.set('Name', accountName);
account.upsert(function(err, results, event) {
if (err) {
alert(err.message);
} else {
console.log(results);
}
});
return false;
}
</script>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment