Hi everyone, So I was looking into Pats thread from some time back and seeing his snippet. Im applying this to a table with different pick list fields.
My question is - How do I point out what picklist to modify and push values to?
Sorry I know this is a highy posted topic, I visited many other posts on this but was not able to narrow down the answer.
Thanks in Advance!
Attached its Pats final code for reference;
--------------------------------------------
value = skuid.utils.decodeHTML(argumentsn1]);
userModel = skuid.model.getModel('User'),
userRow = userModel.getFirstRow(),
userRole = userModel.getFieldValue(userRow,'Contact.Current_Role__c'),
isTeacher = (userRole == 'Teacher'),
grpModel = skuid.model.getModel('Guided Reading Plan'),
grpRow = grpModel.getFirstRow();
// Prevent teachers from making any edits if the status is approved by forcing the mode to read-only
if ((value === 'Reviewed & Approved') && isTeacher) {
field.editable = false;
field.mode = 'read';
}
if (field.mode == 'edit') {
var picklistEntries = field.metadata.picklistEntries;
picklistEntries.length = 0; // if you don't do this, then the "real" values are already in the picklist and the code below will add duplicate values
// if there is no record yet, add a default value. NOTE: when the page is saved, the grp model is only saved when the value in this field is not blank. I am NOT using the Skuid field property "Add 'None' Option" because I only want this option to appear when there isn't already a record.
if (skuid.model.isNewId(grpRow.Id)) {
picklistEntries.push(
{ value: '', label: '-- Select a Status to Create --', defaultValue: false, active: true }
);
}
// create picklist values for the basic statuses
picklistEntries.push(
{ value: 'Working', label: 'Working', defaultValue: false, active: true },
{ value: 'Ready for Review', label: 'Ready for Review', defaultValue: false, active: true }
);
// create picklist values for the review/approval statuses if the user is not a teacher
if (!isTeacher) {
picklistEntries.push(
{ value: 'Reviewed & Approved', label: 'Reviewed & Approved', defaultValue: false, active: true },
{ value: 'Reviewed & Needs Changes', label: 'Reviewed & Needs Changes', defaultValue: false, active: true }
);
}
}
// Run the standard picklist renderer for the given mode
skuid.ui.fieldRenderers/field.metadata.displaytype]pfield.mode](field,value);