Render Recordtype Field as Text, not Url on in Read mode

  • 1
  • Question
  • Updated 5 years ago
  • Answered
Is it possible to add a recordtype field (to a table) such that in edit mode a user can select the recordtype, but in view mode it renders as text instead of Url. Right now when I add recordtypeId it renders as Url to the recordtype object which when clicked takes the user to "Insufficient Privileges" page.
Photo of AndreyVol

AndreyVol

  • 450 Points 250 badge 2x thumb

Posted 5 years ago

  • 1
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Hi Andrey, this custom field renderer should work (I got it from Ben's reply in this topic.)

In the Resources tab, add this Javascript as an inline snippet:


var field = arguments[0],

value = arguments[1];

if (field.mode === 'read') {

field.element.append(skuid.$('<div>').addClass('nx-fieldtext').text(field.model.getFieldValue(field.row,skuid.utils.getFieldReference(field.id,field.metadata))));

} else {

skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);

}



Then, for your RecordTypeId choose Custom as the Field Renderer and then enter whatever you named your snippet.

Let me know how this works for you!
Photo of AndreyVol

AndreyVol

  • 450 Points 250 badge 2x thumb
Thanks Anna,

This worked for me. However, there is one side-effect. With this custom renderer, the edit mode is Auto-Complete. Ideally, in this case it should be "picklist". What should I add to the snippet to render the field as picklist?
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Hi Andrey,

Add this line to the beginning of the else portion of the snippet.



field.options.type = 'REFPICK';
Photo of AndreyVol

AndreyVol

  • 450 Points 250 badge 2x thumb
Perfect! Thanks again.