Conditional Rendering and Edit of field based on other 2 field values

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hi All,

I have a requirement to display field (in detail page) with in line edit based on 2 other field values,

Req: 'Title' is a field on detail page, and Created by & Owner are 2 other field's exposed in detail page. While editing the exiting record in detail page (by using Edit button), it should allow user to edit the 'Title' field for current logged in user only if the loggedin user matches with 'created by' or 'owner' field value.

tried by creating 2 duplicate 'title' field's and not able to apply rendering b/w 2 duplicate 'Title' field's based on 2 other field values which are related user info.

Thanks
Photo of Kailas

Kailas

  • 330 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Two options I can think of immediately:
  1. Create a 'RunningUser' model, and make your rendering conditions for the duplicate title fields based on whether the created by and owner fields match the single specified value of {{$Model.RunningUser.data.0.Id}} (the current user id).
  2. Use a custom field renderer to do it quickly with something like this in javascript:
var field=arguments[0], value = arguments[1], mode = 'read';
if (field.row.CreatedById === skuid.utils.userInfo.userId) mode = 'edit';
skuid.ui.fieldRenderers[field.metadata.displaytype][mode](field,value);
Photo of Kailas

Kailas

  • 330 Points 250 badge 2x thumb
thanks for quick reply Matt...lemme try these options