Problem I am currently working on developing an action for use in Salesforce1 to create a new record of a custom object using a visualforce page and javascript. I'm fairly new to this and can't seem to find what I'm doing wrong anywhere...

<apex:page docType="html-5.0" title="Create Location">     
    <apex:remoteObjects >
        <apex:remoteObjectModel name="Location__c" fields="Id,VIN__c"/>

    <div class="mypage">
        <input type="text" id="myVIN"/>
        <button onclick="createLocation()">Create Location</button>

        function createLocation() {
        var myVIN = document.getElementById("myVIN");
        var location = new sforce.SObject("Location__c");
        location.create({VIN__c: myVIN});


My custom object is Location__c. The it's only custom field is VIN__c, which is required to be input on record creation.

I'm guessing something is going wrong in the createLocation() js function but I'm not too sure. All the examples I could find only work with standard salesforce objects.


It looks like you are assigning the entire myVIN DOM node to the field instead of extracting its value. The last line of your createLocation() function should read:
location.create({VIN__c: myVIN.value});

  • that makes sense but it's still not working.. I do need to include the __c on VIN correct? Is there anything else I need in location.create()? – J. McBride Apr 22 '16 at 17:34
  • 1
    I figured it out, I changed new sforce.Sobject("Location__c") to new sObjectModel.Location__c() – J. McBride Apr 22 '16 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.