Hi I have a picklist of 30 values and selecting any of them would potentially display 1-8 lookups fields. I’m setting up an action on the model that fires when the picklist changes. In the custom snippet, I want to activate a condition on the content types model which contains which of the 8 lookups would be active for the picklist choice. The lookup fields are initially hidden on the UI. How do I render them on the UI when conditions are met? I tried Model.getField(“Company__c”).render(); It’s not working. What should I use for this to work?
Use Conditional Rendering - no code needed.
In my case, I would need 30 conditions for each of the 8 lookups? Any way to do this in javascript? Isn’t action on Model designed for this use case? Also I need to do the same thing on a few other pages in future. Having the conditions hard-coded is hard to maintain.
I’d say Conditional Rendering is designed for this use case – if each of your 8 Lookup Fields should only be active when certain of the 30 Condition Values are selected, then you’re going to have fewer than 30 Conditions for each Lookup field. You have to have this logic somewhere, regardless of how complex it is, so if you can possibly have this logic be defined in the Page Composer, I’d keep it in the Page Composer and not try something in JavaScript — this is what Conditional Rendering is for.
Thanks. The complex logic already exists in an existing custom setting. I bring that data in skuid’s “content types model” as I described in my original question. I’d like to use custom setting instead of hard-coding them in the scattered 8 lookup fields. It’s just easier for sys admin to maintain/deploy and easy to reuse on other future skuid pages by just bringing in the model. Hope that makes sense.
can you describe the custom setting? Does it generate a single boolean for determining whether you should or not show each lookup field? If this is the case you can build a model on the custom setting object and have each lookup conditionally render based on the value of the custom setting.
Correct. I have a model for the custom setting object. Data looks like this:
Type__c , Related_to_company__c, Related_to_Engagement__c, …
" Reference Report Waiver ", yes, no etc…
“Reference Report”, yes, yes, etc…
…
Based on what user selects in the Document Type on the NewDocument model in the field editor,
e.g. if I select " Reference Report Waiver ", I want to show Related_to_company__c, hide Related_to_Engagement__c etc.
So here is my set up in the rendering conditions for the company lookup on the NewDocument object:
1. Related_to_company__c = true on custom setting model
2. Type__c on custom setting model = Type__c user selected on the NewDocument object?
I don’t see an option to do step 2 in the rendering conditions. Thanks!
The model for the custom setting has a condition to check if Type__c = Type__c user selected on the NewDocument model. However, Type__c is empty on the NewDocument on page load. So I need a way to activate that condition through an action, right? That’s why I went with the action on Model approach. But if the conditional rendering can work with the custom setting model, that would be great.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.