Skip to main content
Nintex Community Menu Bar
Question

Picklist renderer (Push) How do you indicate what picklist to control?

  • July 10, 2024
  • 1 reply
  • 0 views

Forum|alt.badge.img+1

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;

--------------------------------------------



var field = arguments[0],
    value = skuid.utils.decodeHTML(arguments[1]);
    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][field.mode](field,value);
Translate
Did this topic help you find an answer to your question?

Forum|alt.badge.img+7

Hi, Jorge,
You said you are working with a table component. Are you trying to figure out how to control:

  1. which picklist field on a single row to update (Example: the table has 3 picklist fields Field1__c, Field2__c, Field3__c; and you want to only update the picklist options for Field1__c), or
  2. which row in the model to update (Example: you have 10 rows in the table, and you want to dynamically generate different picklist values for the same field on different rows… perhaps based on a particular field value in the row)?
I’m just trying to get a better sense of what you’re trying to accomplish, and where you are hitting an issue.
Thanks!
Emily

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings