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>

1 Answer 1

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>
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .