0

The question is in the code comments. Thank you!

<apex:page>
<apex:remoteObjects >
<apex:remoteObjectModel jsShortHand="js" name="myCustomObject__c" fields="Id">
<apex:remoteObjectField name="custom_Field__c">
</apex:remoteObjectField>
</apex:remoteObjectModel>
</apex:remoteObjects>
<div id="dynamicSelectionContainer">
<!--
This page is intentionally not record-specific.
How would I create a html select list where 
each select option is labeled after the RecordType.Name of Schema.SObjectType.myCustomObject__c? 
i also need RecordType.Id to be jquery-accessible, i think as an attribute.
In other words how would I dynamically create 
the html <Select> <Option> markup to give me all Record Types
of  Schema.SObjectType.myCustomObject__c.  
Example: SELECT Id,Name FROM RecordType where sobjectType='myCustomObject__c'
-->
</div>
</apex:page>
3

You can use remoting for this purpose. Here's a generic page that loads the record types for Account (replace with your desired object):

<apex:page >
    <apex:remoteObjects jsNamespace="remoteNS">
        <apex:remoteObjectModel name="RecordType" fields="SObjectType,Name,DeveloperName,Id" />
    </apex:remoteObjects>
    <script>
    var rt = new remoteNS.RecordType();
    rt.retrieve({ where: { SObjectType: { eq: "Account" } } }, function(error, result) {
        result.forEach(function(value){
            var options = document.getElementById("recordTypeOptions");
            var option = document.createElement("option");
            console.log(value);
            option.text = value.get('Name');
            option.value = value.get('Id');
            options.appendChild(option);
       }); 
    });
    </script>
    <select id="recordTypeOptions">

    </select>
</apex:page>
1
  • Thank you. I am testing the answer, I will write-back with the findings. Nov 5 '17 at 15:36

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.