get all available fields of SObject

Hi,
Anyone know how I can get all available fields in an Object in Salesforce. Thisngs I am trying to do is build out a component that user can select fileds and the model will populate with those fields only.

Rebuilding the skuid builder, eh?

I’m not sure there’s a declarative way to grab a full list of fields on an object. I’m not sure of your use case, but the table does have a setting that would “Allow Users to Reorder Columns,” and the users can show and hide columns as needed. You could set up the table’s model to include all of the most commonly used fields, and then leverage this table setting (pulling in every field could could run into Apex heap size errors if you’re pulling too much data into the page). The table settings are found under this icon: 

Thanks Mark,
The thing we are trying to do is, we are removing some of our users completely out of Salesforce and use only skuid. So trying to facilitate the option to create view that users normally create in Salesforce. Is it possible to do that in Skuid?

Thanks,
Tanzir

Tanzir,

It would take quite a bit of work, but I think you could do what you’re after with an approach that leverages the existing skuid page builder.

The skuid builder already has the ability to get a list of fields when given a model, and skuid shows us how to build custom components with a “field” property (see examples of all the available properties here: https://pastebin.com/0iC3xtJn).

I’m guessing that you could build a custom component (and component pack) that would pull in the skuid builder javascript resources into the runtime environment using the manifest files.

Tanzir,

You can get a list of fields for an Object using the FieldDefinition object.  I think there is even a checkbox field that will render true/false for whether the running user should see this field.

Zach McElrath put together a snippet that will save the sort order for a Skuid page. This will give you a starting point for how to manipulate a model on page load using some saved parameters.

https://community.skuid.com/t/capture-sort-order-on-table-component

Thanks,

Bill

Bill,

I’m not quite understanding the FieldDefinition object. How do I tell it what my object is in order to get the fields for it?

Matt,

Here is page that I use with the Field Defintion object:

<skuidpage unsavedchangeswarning="" personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="true">
    <models>
        <model id="User" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="User">
            <fields>
                <field id="Name"/>
                <field id="Id"/>
                <field id="SearchTerm" uionly="true" displaytype="TEXT" label="Search Term"/>
            </fields>
            <conditions>
                <condition type="userinfo" value="" field="Id" state="" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
            </conditions>
            <actions/>
        </model>
        <model id="FieldDefinitions" limit="200" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="FieldDefinition">
            <fields>
                <field id="DeveloperName"/>
                <field id="DataType"/>
                <field id="Label"/>
                <field id="Precision"/>
                <field id="Id"/>
                <field id="EntityDefinitionId"/>
                <field id="ControllingFieldDefinitionId"/>
                <field id="NamespacePrefix"/>
                <field id="MasterLabel"/>
                <field id="QualifiedApiName"/>
                <field id="Length"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="Account" enclosevalueinquotes="true" field="EntityDefinition.QualifiedApiName" operator="=" state="filterableon" inactive="false" name="EntityDefinitionId"/>
                <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Label" state="filterableoff" inactive="true" name="Label" operator="contains"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="FieldDefinitions" uniqueid="sk-Sw6Bc-278">
            <maintitle>Field Definitions</maintitle>
            <actions/>
        </pagetitle>
        <panelset type="standard" uniqueid="sk-SyXu1-530" scroll="">
            <panels>
                <panel type="left" width="225px">
                    <components>
                        <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="User" buttonposition="" uniqueid="sk-SyaO4-542" mode="edit">
                            <columns>
                                <column width="100%">
                                    <sections>
                                        <section title="Search" collapsible="no" showheader="false">
                                            <fields>
                                                <field uniqueid="sk-Sy-fz-593" id="SearchTerm"/>
                                            </fields>
                                        </section>
                                    </sections>
                                </column>
                            </columns>
                        </basicfieldeditor>
                        <buttonset model="User" uniqueid="sk-Sysh--570" position="left">
                            <buttons>
                                <button type="multi" label="Search" uniqueid="sk-Syt9q-575" icon="sk-icon-search">
                                    <actions>
                                        <action type="setCondition" model="FieldDefinitions" condition="Label" value="{{$Model.User.data.0.SearchTerm}}"/>
                                        <action type="requeryModel" model="FieldDefinitions" behavior="standard"/>
                                    </actions>
                                </button>
                                <button type="multi" label="Clear Search" uniqueid="sk-SzNcr-182" icon="sk-icon-cancel">
                                    <actions>
                                        <action type="updateRow" fieldmodel="User" affectedrows="context" field="SearchTerm" enclosevalueinquotes="true"/>
                                        <action type="deactivateCondition" model="FieldDefinitions" condition="Label"/>
                                        <action type="requeryModel" model="FieldDefinitions" behavior="standard"/>
                                    </actions>
                                </button>
                                <button type="multi" label="Query" uniqueid="sk-T6CPt-287" icon="sk-icon-refresh">
                                    <actions>
                                        <action type="requeryModel" model="FieldDefinitions" behavior="standard"/>
                                    </actions>
                                </button>
                            </buttons>
                            <renderconditions logictype="and"/>
                        </buttonset>
                    </components>
                </panel>
                <panel>
                    <components>
                        <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="client" searchbox="false" showexportbuttons="true" pagesize="all" alwaysresetpagination="false" createrecords="false" model="FieldDefinitions" buttonposition="left" mode="readonly" allowcolumnreordering="false" responsive="false" uniqueid="sk-SuHVb-97" emptysearchbehavior="query" tokenizesearch="true" instantfilters="false">
                            <fields>
                                <field id="Label" hideable="true" uniqueid="fi-SuK2c-117" valuehalign="" type=""/>
                                <field id="QualifiedApiName" hideable="true" uniqueid="fi-31lF52-257" valuehalign="" type=""/>
                                <field id="DataType" hideable="true" uniqueid="fi-SuK2Y-116"/>
                                <field id="Precision" hideable="true" uniqueid="fi-SuK2g-119" valuehalign="" type=""/>
                                <field id="Length" hideable="true" uniqueid="fi-31lQdQ-313" valuehalign="" type=""/>
                                <field id="NamespacePrefix" hideable="true" uniqueid="fi-31l0xN-203" valuehalign="" type=""/>
                            </fields>
                            <rowactions/>
                            <massactions usefirstitemasdefault="true"/>
                            <views>
                                <view type="standard"/>
                            </views>
                            <filters>
                                <filter type="select" filteroffoptionlabel="New Filter" createfilteroffoption="false" affectcookies="true" autocompthreshold="25" conditionsource="manual" labelmode="no" condition="EntityDefinitionId">
                                    <sources>
                                        <source type="manual" effectsbehavior="justdefault">
                                            <options>
                                                <option label="Account" type="simple" value="Account"/>
                                                <option label="Contact" type="simple" value="Contact"/>
                                                <option label="Opportunity" type="simple" value="Opportunity"/>
                                                <option label="Lead" type="simple" value="Lead"/>
                                                <option label="Task" type="simple" value="Task"/>
                                                <option label="Event" type="simple" value="Event"/>
                                            </options>
                                        </source>
                                    </sources>
                                </filter>
                            </filters>
                            <searchfields/>
                            <exportproperties usetablecolumns="true" appendrowidcolumn="false" loadallrecords="true"/>
                        </skootable>
                    </components>
                </panel>
            </panels>
        </panelset>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Thanks,

Bill

That works like a champ