Featured Video Play Icon

This video exposes one of subtle ways in which Skuid has a very mature product. This is knowing about and making use of Context within models in order to only need one model to:

  1. Manage a set of records
  2. Create new records
<skuidpage showsidebar="false" showheader="true" tabtooverride="Opportunities" unsavedchangeswarning="">
   <labels/>
   <models>
      <model id="OwnerData" limit="101" query="true" createrowifnonefound="false" sobject="User" orderby="Name">
         <fields>
            <field id="Name"/>
            <field id="Id"/>
         </fields>
         <conditions>
            <condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="IsActive"/>
         </conditions>
         <actions/>
      </model>
      <model id="opportunities" limit="25" query="true" createrowifnonefound="false" orderby="Name" sobject="Opportunity">
         <fields>
            <field id="AccountId"/>
            <field id="Amount"/>
            <field id="CloseDate"/>
            <field id="IsClosed"/>
            <field id="Account.Name"/>
            <field id="NextStep"/>
            <field id="Name"/>
            <field id="Probability"/>
            <field id="StageName"/>
            <field id="OwnerId"/>
            <field id="Owner.Name"/>
            <field id="LeadSource"/>
            <field id="Owner.Email"/>
            <field id="CreatedDate"/>
            <field id="Account.Phone"/>
            <field id="CreatedById"/>
            <field id="CreatedBy.Name"/>
            <field id="OpportunityLineItems" type="childRelationship">
               <fields>
                  <field id="TotalPrice"/>
                  <field id="PricebookEntry.Product2.Name"/>
                  <field id="Quantity"/>
                  <field id="UnitPrice"/>
               </fields>
            </field>
            <field id="Type"/>
            <field id="CampaignId"/>
            <field id="Campaign.Name"/>
            <field id="Description"/>
            <field id="TotalOpportunityQuantity"/>
            <field id="Pricebook2Id"/>
            <field id="Pricebook2.Name"/>
         </fields>
         <conditions>
            <condition type="fieldvalue" enclosevalueinquotes="true" operator="=" value="" field="StageName" name="OppStage" state="filterableoff" inactive="true"/>
            <condition type="fieldvalue" enclosevalueinquotes="true" operator="=" value="" field="LeadSource" name="OppLeadSource" state="filterableoff" inactive="true"/>
            <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Type" state="filterableoff" inactive="true" name="Type"/>
            <condition type="fieldvalue" value="" enclosevalueinquotes="false" field="CloseDate" state="filterableoff" inactive="true" name="CloseDate"/>
            <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="OwnerId" state="filterableoff" inactive="true" name="OwnerId"/>
            <condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="IsClosed" state="filterableoff" inactive="true" name="IsClosedTrue"/>
            <condition type="fieldvalue" value="" enclosevalueinquotes="false" field="CloseDate" state="filterableoff" inactive="true" name="CloseDate1"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="opportunities">
         <actions>
            <!--
            <action type="redirect" label="Standard Page" window="self" icon="ui-silk-application-form" url="/{{Model.KeyPrefix}}/o?nooverride=1"/>
            -->
            <action type="savecancel" label="New Action">
               <cancelhotkeys/>
            </action>
         </actions>
         <subtitle>Home</subtitle>
         <maintitle>{{Model.LabelPlural}}</maintitle>
         <renderconditions logictype="and"/>
      </pagetitle>
      <skootable showconditions="true" showsavecancel="false" searchbox="true" searchmethod="server" createrecords="false" model="opportunities" pagesize="10" showexportbuttons="true" mode="read">
         <fields>
            <field id="Name" allowordering="true" columnwidth="20%"/>
            <field id="Type"/>
            <field id="Amount" countBlanks="false" allowordering="true">
               <summaries>
                  <summary>sum</summary>
                  <summary>avg</summary>
               </summaries>
            </field>
            <field id="TotalOpportunityQuantity" allowordering="true" readonly="true">
               <summaries>
                  <summary>sum</summary>
                  <summary>avg</summary>
               </summaries>
            </field>
            <field id="AccountId" allowordering="true" type="REFPICK">
               <label>Company Name</label>
            </field>
            <field id="StageName" allowordering="true" type=""/>
            <field id="Probability"/>
            <field id="CloseDate" allowordering="true"/>
            <field id="OwnerId">
               <label>Owner</label>
            </field>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
            <action type="redirect" label="Email Owner" url="/_ui/core/email/author/EmailAuthor?rtype=003&amp;p24={{{Owner.Email}}}&amp;p3_lkid={{{Id}}}&amp;retURL=%2F006%2Fo" icon="ui-silk-email-go" window="self"/>
            <action type="popup" window="self" icon="ui-silk-application" label="View Opportunity Details">
               <popup title="{{Name}}" width="90%">
                  <components>
                     <pagetitle model="opportunities">
                        <maintitle>{{{Name}}}</maintitle>
                        <subtitle>
                           <template>{{Model.Label}}</template>
                        </subtitle>
                        <actions>
                           <action type="redirect" window="self" label="Open Full Detail" icon="ui-silk-application-go" url="/{{{Id}}}"/>
                           <action type="savecancel" label="" snippet="" icon="">
                              <models/>
                           </action>
                        </actions>
                        <conditions>
                           <condition type="contextrow" field="Id" autocreated="true"/>
                        </conditions>
                     </pagetitle>
                     <tabset rememberlastusertab="true" defertabrendering="true">
                        <tabs>
                           <tab name="Basics" icon="ui-silk-award-star-gold-2">
                              <components>
                                 <basicfieldeditor showheader="true" showsavecancel="false" model="opportunities" mode="read" layout="above" buttonposition="">
                                    <columns>
                                       <column width="50%">
                                          <sections>
                                             <section title="Opportunity Details">
                                                <fields>
                                                   <field id="AccountId">
                                                      <label>Company</label>
                                                   </field>
                                                   <field id="Amount"/>
                                                   <field id="OwnerId">
                                                      <label>Owner</label>
                                                   </field>
                                                </fields>
                                             </section>
                                             <section title="Line Items">
                                                <fields>
                                                   <field id="OpportunityLineItems" type="CHILDREL" limit="100" delimiter="&lt;br/&gt;">
                                                      <label>Quantity of Product at Sales Price</label>
                                                      <template>{{Quantity}} {{PricebookEntry.Product2.Name}} @ {{UnitPrice}}</template>
                                                   </field>
                                                </fields>
                                             </section>
                                          </sections>
                                       </column>
                                       <column width="50%">
                                          <sections>
                                             <section title="Status">
                                                <fields>
                                                   <field id="CloseDate"/>
                                                   <field id="NextStep"/>
                                                   <field id="Probability"/>
                                                </fields>
                                             </section>
                                          </sections>
                                       </column>
                                    </columns>
                                    <conditions>
                                       <condition type="contextrow" field="Id" autocreated="true"/>
                                    </conditions>
                                 </basicfieldeditor>
                              </components>
                           </tab>
                           <tab name="Line Items" icon="ui-silk-cart">
                              <components>
                                 <basicfieldeditor showheader="true" showsavecancel="false" model="opportunities" mode="read" uniqueid="SelectPricebook">
                                    <columns>
                                       <column width="50%">
                                          <sections>
                                             <section title="Opportunity Pricebook">
                                                <fields>
                                                   <field id="Pricebook2Id" required="false" type="REFPICK" optionsource="model" optionmodel="Pricebooks" displaytemplate="{{Name}}">
                                                      <filters/>
                                                   </field>
                                                </fields>
                                             </section>
                                          </sections>
                                       </column>
                                    </columns>
                                    <conditions>
                                       <condition type="contextrow" field="Id"/>
                                    </conditions>
                                 </basicfieldeditor>
                                 <custom name="HideLineItemsTableIfNoPricebook_ExistingOpp"/>
                              </components>
                           </tab>
                        </tabs>
                     </tabset>
                     <custom name="LoadChildData"/>
                  </components>
               </popup>
            </action>
            <action type="redirect" label="Clone" url="/{{Id}}/e?clone=1" icon="ui-silk-arrow-branch" window="self"/>
         </rowactions>
         <actions defaultlabel="Global Actions" defaulticon="ui-silk-wand" usefirstitemasdefault="true">
            <action type="multi" label="New Opp in Popup" icon="sk-icon-add">
               <actions>
                  <action type="createRow" model="opportunities" appendorprepend="append" defaultmodefornewitems="edit"/>
                  <action type="showPopup">
                     <popup title="New Opportunity" uniqueid="newOppPopup" width="90%">
                        <components>
                           <pagetitle model="opportunities" uniqueid="popupPageTitle">
                              <maintitle>
                                 <template>{{Name}}</template>
                              </maintitle>
                              <subtitle>
                                 <template>{{Model.label}}</template>
                              </subtitle>
                              <actions>
                                 <action type="multi" label="Save and Close" icon="sk-icon-save">
                                    <actions>
                                       <action type="blockUI" message="Saving"/>
                                       <action type="save">
                                          <models>
                                             <model>opportunities</model>
                                          </models>
                                          <onerroractions>
                                             <action type="blockUI" message="There was an error saving Opportunity" timeout="3000"/>
                                          </onerroractions>
                                       </action>
                                       <action type="closeTopmostPopup"/>
                                       <action type="unblockUI"/>
                                    </actions>
                                 </action>
                              </actions>
                           </pagetitle>
                           <basicfieldeditor showheader="true" showsavecancel="false" model="opportunities" buttonposition="" mode="edit" layout="">
                              <columns>
                                 <column width="33.3%">
                                    <sections>
                                       <section title="Basic Information" collapsible="no">
                                          <fields>
                                             <field id="Name"/>
                                             <field id="AccountId"/>
                                             <field id="Type"/>
                                             <field id="Description"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                                 <column width="33.3%">
                                    <sections>
                                       <section title="Sales Process" collapsible="no">
                                          <fields>
                                             <field id="StageName"/>
                                             <field id="CloseDate"/>
                                             <field id="NextStep"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                                 <column width="33.3%">
                                    <sections>
                                       <section title="System Information" collapsible="no">
                                          <fields>
                                             <field id="LeadSource"/>
                                             <field id="CampaignId"/>
                                             <field id="OwnerId"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                              </columns>
                              <conditions>
                                 <condition type="contextrow" field="Id" mergefield="Id"/>
                              </conditions>
                           </basicfieldeditor>
                        </components>
                     </popup>
                  </action>
                  <action type="custom" snippet="listenForPopupClose"/>
               </actions>
            </action>
         </actions>
         <massactions defaultlabel="Mass Actions" defaulticon="ui-silk-wand" usefirstitemasdefault="true">
            <action type="massupdate"/>
            <action type="massdelete"/>
            <action type="massedit"/>
         </massactions>
         <filters>
            <filter type="select" filteroffoptionlabel="Any Close Date" createfilteroffoption="true" condition="CloseDate">
               <sources>
                  <source type="manual">
                     <options>
                        <option label="Closing: This Month" type="simple" value="THIS_MONTH"/>
                        <option label="Closing: Next 30 Days" type="simple" value="NEXT_N_DAYS:30"/>
                        <option label="Closing: Next 90 Days" type="simple" value="NEXT_N_DAYS:90"/>
                        <option label="Closing: This Fiscal Quarter" type="simple" value="THIS_FISCAL_QUARTER"/>
                        <option label="Closing: Next Fiscal Quarter" type="simple" value="NEXT_FISCAL_QUARTER"/>
                        <option label="Closing: This Year" type="simple" value="THIS_YEAR"/>
                        <option label="Closing: Last 30 Days" type="simple" value="LAST_N_DAYS:30"/>
                        <option label="Closing: Last 90 Days" type="simple" value="LAST_N_DAYS:90"/>
                        <option label="Closing: Last Year" type="simple" value="LAST_YEAR"/>
                     </options>
                  </source>
               </sources>
            </filter>
            <filter type="select" filteroffoptionlabel="Any Stage" createfilteroffoption="true" condition="OppStage">
               <sources>
                  <source type="metadata" effectsbehavior="justdefault"/>
                  <source type="manual">
                     <options>
                        <option label="Random Group" type="complex">
                           <effects>
                              <effect action="set" value="Prospecting" condition="OppStage"/>
                              <effect action="set" value="Qualification" condition="OppStage"/>
                           </effects>
                        </option>
                     </options>
                  </source>
               </sources>
            </filter>
            <filter type="select" filteroffoptionlabel="Any Type" createfilteroffoption="true" condition="Type">
               <sources>
                  <source type="metadata" prefix="Type: "/>
               </sources>
            </filter>
            <filter type="select" filteroffoptionlabel="Any Owner" createfilteroffoption="true" affectcookies="true" condition="OwnerId">
               <sources>
                  <source type="model" model="OwnerData" effectsbehavior="justdefault">
                     <labeltemplate>Owner: {{{Name}}}</labeltemplate>
                     <valuetemplate>{{Id}}</valuetemplate>
                  </source>
               </sources>
            </filter>
            <filter type="toggle" filteroffoptionlabel="New Filter" createfilteroffoption="true" affectcookies="true" label="Just Closed Opportunities">
               <effects>
                  <effect action="activate" value="" condition="IsClosedTrue"/>
               </effects>
            </filter>
         </filters>
         <exportproperties usetablecolumns="true"/>
         <renderconditions logictype="and"/>
      </skootable>
   </components>
   <resources>
      <labels/>
<script>
<javascript>
         <jsitem location="inlinesnippet" name="listenForPopupClose" cachelocation="false">var params = arguments[0],
	$ = skuid.$,
	oppModel = skuid.$M('opportunities');

    skuid.$(".ui-dialog-content").dialog({
    "beforeClose" : function()
      {
        //put your event-handler code here.
        oppModel.cancel();
      }
    });</jsitem>
      </javascript>
</script>
      <css/>
   </resources>
</skuidpage>