Assign picklist values from a global picklist to UI-only picklist

edited June 2019 in Questions
Is there a way to assign picklist entries to a UI-only picklist field in a UI only model from a global picklist? In my case I just have a simple UI-only picklist field that needs to have all the 50 states as its picklist values. Instead of typing in all the 50 states, I was wondering if I could connect it to an already existing global picklist field. I see that it could be populated by "Rows in a model" or "Javascript snippet" but how do I put that to use here?

Comments

  • Matthew LeahyMatthew Leahy ✭✭✭
    edited February 2018
    Hi Ashwat,

    Salesforce does not give direct access to global picklist value sets. You can certainly use picklist fileds that use a global picklist value set, but I don't think that's what you're after.

  • edited June 2019
    Ashwat,

    Please give this a try.  I pulled in a model (Contact) with a field (Salutation) that has a pick list that I want to use.  I am creating a Task and I add a UI Only field that is of type Pick List.  I add a custom field render and pull the pick list entries from the Salutation field and use them with the UI Only field.

    Thanks,

    Bill

    <skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Task">
        <models>
            <model id="Contact" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
                <fields>
                    <field id="Salutation"/>
                </fields>
                <conditions/>
                <actions/>
            </model>
            <model id="Task" limit="1" query="false" createrowifnonefound="true" datasource="salesforce" sobject="Task" type="">
                <fields>
                    <field id="Subject"/>
                    <field id="Picklist" uionly="true" displaytype="PICKLIST" label="Picklist" ogdisplaytype="TEXT" picklistsource="manual" snippet="getPicklist">
                        <picklistentries/>
                    </field>
                </fields>
                <conditions/>
                <actions/>
            </model>
        </models>
        <components>
            <pagetitle model="Task" uniqueid="sk-1HSEX_-197">
                <maintitle>
                    <template>New {{Model.label}}</template>
                </maintitle>
                <subtitle>
                    <template>{{Model.labelPlural}}</template>
                </subtitle>
                <actions>
                    <action type="savecancel" afterCancel="/{{Model.KeyPrefix}}/o" afterSave="/{{Id}}" rollbackonanyerror="true" uniqueid="sk-1HSEXz-195"/>
                </actions>
            </pagetitle>
            <basicfieldeditor showsavecancel="false" showheader="true" model="Task" mode="edit" uniqueid="sk-1HSEYG-210">
                <columns>
                    <column width="50%">
                        <sections>
                            <section title="Basics">
                                <fields>
                                    <field id="Subject" uniqueid="sk-1HSEY6-205"/>
                                </fields>
                            </section>
                        </sections>
                    </column>
                    <column width="50%">
                        <sections>
                            <section title="Additional Info">
                                <fields>
                                    <field uniqueid="sk-1HSx4g-499" id="Picklist" valuehalign="" type="CUSTOM" snippet="getPicklist"/>
                                </fields>
                            </section>
                        </sections>
                    </column>
                </columns>
            </basicfieldeditor>
        </components>
        <resources>
            <labels/>
            <css/>
            <javascript>
                <jsitem location="inlinesnippet" name="getPicklist" cachelocation="false">var params = arguments[0],
        value = arguments[1];
    $ = skuid.$;

    console.log(params.metadata.picklistEntries);

    var con=skuid.model.map().Contact;
    console.log('Contact');
    console.log(con.fields[0].picklistEntries);

    // Get the Running User's Profile Name from a 'RunningUser' model:

    if (params.mode == 'edit') {
        params.metadata.picklistEntries=con.fields[0].picklistEntries;
    //    pick.push(con.fields[0].picklistEntries);
    }

    // Run the standard picklist renderer for the given mode
    skuid.ui.fieldRenderers[params.metadata.displaytype][params.mode](params,value);
    </jsitem>
            </javascript>
            <actionsequences uniqueid="sk-1HSIca-288"/>
        </resources>
        <styles>
            <styleitem type="background" bgtype="none"/>
        </styles>
    </skuidpage>



  • edited August 2018
    Works like a charm, Bill.
  • edited June 2019
    worked super smooth Bill. Thanks. Now just need to get it doing dependencies ;). Thanks again, seriously!
Sign In or Register to comment.