How do I use the isAvailable() property on the Record Type Metadata Object?

So this is pretty old, but I came back to this recently and figured out how to use isAvailable to generate the correct record type picklist for a given user.  This uses a custom field renderer snippet on the Record Type field.  Sharing it here in case it helps others, or if anyone has suggestions for improving.  For example, there is probably a better way to handle the fact that this won’t work unless it is called as the field renderer from the RecordTypeID field.  Also, I set the field to required, but not sure how to have it show with the red border.  I am not so experienced with custom field renderers, so I used the example here as a starting point (thanks, J!).  Suggestions welcome!

The below is from a static resource snippet setup, so might need to be adjusted for inline snippets.

( function( skuid, $ ){ var snippet = skuid.snippet, ui = skuid.ui; snippet.registerSnippet( 'availableRecordTypesPicklist', function(){ var field = arguments[0], value = arguments[1], fieldName = field.id, model = field.model, row = field.row; // Proceed if this renderer was called from record type field if( fieldName == 'RecordTypeId' ){ if( field.mode === 'edit' ){ // Build picklist options var availRecTypes = []; // Loop through each record type in the field's model $.each( model.recordTypeInfos, function( i, rt ){ // Build list of record types available to the user (except the master) if( rt.isAvailable && ( rt.isMaster == undefined || !rt.isMaster ) ){ availRecTypes.push({ value : rt.recordTypeId, // Will be stored in target object label : rt.name // Will display in picklist }); } }); // Render the options as a PICKLIST var availRecTypesPicklist = ui.renderers.PICKLIST.edit({ entries : availRecTypes, required : true, value : value }).change( function(){ // Update the row in the target object model.updateRow( row, fieldName, $( this ).val() ); }); // Append the PICKLIST to the DOM element field.element.append( availRecTypesPicklist ); } else { // If the mode is anything other than edit, display the field as Text ui.fieldRenderers.TEXT[ field.mode ]( field, model.getFieldValue( row, 'RecordType.Name' ) ); } } else { // If renderer not called from record type field, warning message console.log( 'This custom field renderer must be called from record type field' ); } }); }( skuid, skuid.$ ));