Conditional field value w/ data from another Model

  • 1
  • Question
  • Updated 2 years ago
  • Answered
We would like to conditionally render one of two hyperlinks or a blank space in a Table field, based upon the value from a Model set up strictly for this purpose. It looks like we're having an issue where the browser "Cannot read property 'displaytype' of undefined", but I can't quite figure out where my data calls are going wrong -- or whether there might be another issue.

var field = '{{$Model.AOPStatus.fieldsmap.name.AoP_Status__c}}',
    value = '{{$Model.AOPStatus.data.0.AoP_Status__c}}',
    stringValue = value.toString();
	$ = skuid.$;
	
switch(value)
{
    case 'Ready for Review' :
        stringValue = '<a href = "/apex/skuid__ui?page=SSA-Counselor-Approval-of-Participation">For Your Review</a>';
        break;
        
    case 'Ready for Review' :
        stringValue = 'Approval Completed';
        break;

    default :
        stringvalue = null;
        break;
}
    
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,stringValue);
Photo of Daniel Kray

Daniel Kray

  • 70 Points

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,014 Points 20k badge 2x thumb
(a) Is this Table field essentially read-only? If so, you should add a Ui-Only Formula Field and just show that. Then the Formula can determine what content to display in the column. 

(b) As of the Brooklyn release, coming out at the end of November, there will be Conditional Rendering of Table Columns so you shouldn't need to do this at all, you'll just be able to have 2 / 3 separate Table columns, and Conditionally Render them.

(c) As to the code above, I'm not sure why you're setting field to the result of a merge, that definitely will be problematic, just set it to the first argument, like this:

var field = arguments[0],

And try that.