Create new records in detail page view

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I'm having issues with creating a new record when you're in a detailed page. For example, in a company detailed view, I'd like to be able to "Create New Contact" and have a pop up window that will you create that contact, put the company name and it would add that contact to the company. 

However, when I create a NewContact model, and add this popup, every contact shows up. 

I just want a blank, edit create new contact pop up window. 

Please help.
Photo of Julien Jacques

Julien Jacques

  • 364 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
The issue is with the model setup first and maybe the actions you're using. Putting XML together. One minute.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Go to the model's advanced tab and uncheck "Load Model data on page load". You probably also want to check "Create default row if Model has none".
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Not a fan of the "Create default row if Model has none" unless it's for a page that is exclusively for creating new records. I prefer to always empty model data prior to creating a new record.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true">
   <models>
      <model id="Account" limit="1" query="true" createrowifnonefound="false" doclone="" type="" sobject="Account">
         <fields>
            <field id="Name"/>
            <field id="Phone"/>
         </fields>
         <conditions>
            <condition type="param" value="id" field="Id" operator="=" enclosevalueinquotes="true" novaluebehavior=""/>
         </conditions>
         <actions/>
      </model>
      <model id="AccountContacts" limit="" query="true" createrowifnonefound="false" sobject="Contact" doclone="" type="">
         <fields>
            <field id="Name"/>
            <field id="Phone"/>
            <field id="FirstName"/>
            <field id="LastName"/>
         </fields>
         <conditions>
            <condition type="modelmerge" value="" field="AccountId" operator="=" model="Account" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
         </conditions>
         <actions/>
      </model>
      <model id="NewContact" limit="" query="false" createrowifnonefound="false" sobject="Contact" doclone="" type="">
         <fields>
            <field id="FirstName"/>
            <field id="LastName"/>
            <field id="Phone"/>
         </fields>
         <conditions>
            <condition type="modelmerge" value="" field="AccountId" operator="=" model="Account" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Account">
         <maintitle>
            <template>{{Name}}</template>
         </maintitle>
         <subtitle>
            <template>{{Model.label}}</template>
         </subtitle>
         <actions>
            <action type="savecancel">
               <models>
                  <model>AccountContacts</model>
               </models>
            </action>
            <action type="multi" label="New Contact" icon="sk-icon-add">
               <actions>
                  <action type="emptyModelData">
                     <models>
                        <model>NewContact</model>
                     </models>
                  </action>
                  <action type="createRow" model="NewContact" appendorprepend="append" defaultmodefornewitems="edit"/>
                  <action type="showPopup">
                     <popup title="New Popup" width="600">
                        <components>
                           <pagetitle model="NewContact">
                              <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="save">
                                          <models>
                                             <model>NewContact</model>
                                          </models>
                                       </action>
                                       <action type="requeryModels" behavior="standard">
                                          <models>
                                             <model>AccountContacts</model>
                                          </models>
                                       </action>
                                       <action type="closeTopmostPopup"/>
                                    </actions>
                                 </action>
                                 <action type="multi" label="Cancel" icon="sk-icon-cancel">
                                    <actions>
                                       <action type="emptyModelData"/>
                                       <action type="closeTopmostPopup"/>
                                    </actions>
                                 </action>
                              </actions>
                           </pagetitle>
                           <basicfieldeditor showheader="true" showsavecancel="false" model="NewContact" buttonposition="" mode="edit" layout="">
                              <columns>
                                 <column width="100%">
                                    <sections>
                                       <section title="Section A" collapsible="no">
                                          <fields>
                                             <field id="FirstName"/>
                                             <field id="LastName"/>
                                             <field id="Phone"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                              </columns>
                           </basicfieldeditor>
                        </components>
                     </popup>
                  </action>
               </actions>
            </action>
         </actions>
      </pagetitle>
      <basicfieldeditor showheader="true" showsavecancel="false" model="Account" buttonposition="" mode="read" layout="">
         <columns>
            <column width="100%">
               <sections>
                  <section title="Section A" collapsible="no">
                     <fields>
                        <field id="Name"/>
                        <field id="Phone"/>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
      <skootable showconditions="true" showsavecancel="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="AccountContacts" buttonposition="" mode="read">
         <fields>
            <field id="Name"/>
            <field id="Phone"/>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
         </rowactions>
         <massactions usefirstitemasdefault="true">
            <action type="massupdate"/>
            <action type="massdelete"/>
         </massactions>
         <views>
            <view type="standard"/>
         </views>
         <actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true"/>
      </skootable>
   </components>
   <resources>
      <labels/>
      <javascript/>
      <css/>
   </resources>
</skuidpage>
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,270 Points 5k badge 2x thumb
Found an old skuid blog post that referenced the time before there were multiple actions. I feel like I've gone that transition as a user these past couple weeks, a little nervous about using them, didn't think I needed them, to know going back and redoing entire pages based on using them. It actually took a few reps in the mobile page builder, where things are a little more limited and less intuitive, to realize how helpful multiple actions are. Anyway, Thanks for this code!
Photo of Julien Jacques

Julien Jacques

  • 364 Points 250 badge 2x thumb
Hey Pat. Super newb question but is this a whole new skuidpage or can copy paste this code in a Template?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Whole new skuid page for you to peruse how I would approach it. Create a new page and paste.

Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
I was a newb as well just a few months ago. ;)
Photo of Julien Jacques

Julien Jacques

  • 364 Points 250 badge 2x thumb
Hmm. I don't think this will work. It's a consistent problem on all of my pages to create a new record of the same record type. 

Thanks though. It looks like Moshe's suggestion is working... ish
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Give me a ring on Skype if you'd like to review. pat.vachon.77