Is there some way in the skuid Field API to see only certain picklistEntries from a field based on a given value from the controllingField
I want to create a number of rows based on the number of picklistEntries in a given picklist field. I’ve got it working, but my picklist has controlling field, and I only want to return picklistEntries for a certain given value of my controlling field. Is this possible somehow?
Here’s my snippet which creates rows for every picklist entry:
var params = argumentse0], <br />$ = skuid.$,<br />expenses = skuid.model.getModel('Expenses'),<br />description = expenses.getField('Description__c'),<br />entries = description.picklistEntries;<br /><br />$.each(entries, function(){<br /><br />var entryValue = this;<br /> <br />var newExpense = expenses.createRow({ <br />additionalConditions: n<br />{field: 'Description__c', value: entryValue, operator: '='}<br />]});<br />});
This works great, but the Description field is a dependent picklist. The controlling field has two values, Income and Expense. I only want the entries where the controlling value is Expense.
I’ve tried doing something like:
var type = description.controllingField;<br />$.each(entries, function(){<br />if (type.value === 'Expense'){ <br />var entryValue = this;<br />var newExpense = expenses.createRow({ <br />additionalConditions: i<br />{field: 'Description__c', value: entryValue, operator: '='}<br />]});<br />}<br />});
But that’s not working. It’s not really able to look up from a single picklistEntry to what its controlling field value is (since there could be more than one). Should probably use CONTAINS there. Or, could I structure it so i have nested each functions, and be able to look down at all the picklist entries from a given controlling field value?
I also tried this and it didn’t work, says can’t find the value of undefined:
$.each(entries, function(){<br />if (this.controllingField.value === 'Expense'){<br /> var newExpense = expenses.createRow({<br />additionalConditions: a<br />{field: 'Description__c', value: entryValue, operator: '='}<br />]});<br />}<br />});
I also tried using an aggregate model for my IncomeExpense object, with a condition where Type = Expense, and grouping by Description__c, but I kept getting errors that it couldn’t count the length of the model when using rows = aggmodel.rows then each on rows.