This is an update to another video I made. I’ve bolded what’s new below.
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:
- Manage a set of records
- Create new records
- Dynamically cancel new record using a generic snippet
<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_All" 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"/> <field id="Shares" type="childRelationship" limit="10"> <fields> <field id="OpportunityAccessLevel"/> <field id="OpportunityId"/> </fields> </field> <field id="Cirrus_Files_Nest_Under__c"/> <field id="Id"/> </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"/> <condition type="join" value="" field="Id" operator="in" enclosevalueinquotes="true" joinobject="OpportunityShare" joinfield="OpportunityId"> <conditions> <condition type="fieldvalue" value="All" enclosevalueinquotes="true" field="OpportunityAccessLevel" operator="="/> </conditions> </condition> </conditions> <actions/> </model> </models> <components> <skootable showconditions="true" showsavecancel="false" searchbox="true" searchmethod="server" createrecords="false" model="opportunities_All" 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> <field id="Shares" type="CHILDREL" limit="100" valuehalign="" delimiter="," allowhtml="true"> <label>Opportunity Access</label> <template><div id="{{OpportunityId}}">{{OpportunityAccessLevel}}</div></template> </field> </fields> <rowactions> <action type="edit"/> <action type="delete"/> </rowactions> <actions defaultlabel="Global Actions" defaulticon="ui-silk-wand" usefirstitemasdefault="true"> <action type="multi" label="New Opp" icon="sk-icon-add"> <actions> <action type="createRow" model="opportunities_All" appendorprepend="append" defaultmodefornewitems="edit"/> <action type="showPopup"> <popup title="New Opportunity" uniqueid="newOppPopup" width="90%"> <components> <basicfieldeditor showheader="true" showsavecancel="false" model="opportunities_All" 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/> <javascript> <jsitem location="inlinesnippet" name="listenForPopupClose" cachelocation="false">var params = arguments[0], $ = skuid.$, model = params.context.model; skuid.$(".ui-dialog-content").dialog({ "beforeClose" : function() { //put your event-handler code here. model.cancel(); } });</jsitem> <jsitem location="inline" name="inline" cachelocation="false" url="">(function(skuid){ var $ = skuid.$; $(function(){ var oppModel = skuid.$M('opportunities_All'); $.each(oppModel.data, function(r,oppRow){ var pound = "#", oppId = oppRow.Id, oppIdId = pound.concat(oppId); if($(oppIdId).text().indexOf("Edit") == -1) { $(oppIdId).closest('tr').find('.nx-skootable-buttonicon.editrow').hide(); } }); }); })(skuid);</jsitem> </javascript> <css/> </resources> </skuidpage>