file upload issue

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have followed the direction to "Use the File Component to Attach Files to a Record".  If I leave as "deactivate this condition" "If no row or Source Model", then all records regardless of the Parent ID (assume because it finds no matches, so it gives me all records) are presented and when I drag a file to upload the records shows.


If I change "If no row in source model" then the model shows no records as it should.  However, if I drag a document to "File Upload" the record does not show in the table. 
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Bill,

Would you post pictures of your attachment model and your parent model.  Please also show us the model conditions on your attachment model.

Thanks,

Bill
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
Thanks Bill


Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Bill,

Thanks for the screenshots.  I think there are 2 things that you want to do.  In your attachment model (Attachment_CR) change the condition for the ParentId.   You have it set for Parent.Id (Parent dot Id).  I want you to set it to 'ParentId' as below.

The other thing I saw is that you do not load the A_Temp_Add_Task_CR__c model on page load.  If this model has no data, then the Attachment model condition to filter by ParentId will be empty meaning that when it is set to 'deactivate this condition' the Attachment model will load ANY attachments that the user can see.  As you have noted if you set the condition to 'Abort if no rows in source model', then nothing comes back since the A_Temp_Add_Task_CR__c is empty meaning there is no Id field to filter the Attachment model.

How are you intending to use the A_Temp_Add_Task_CR__c model?  If this is for creating new records in the A_Temp_Add_Task_CR__c object then you will need to save the A_Temp_Add_Task_CR__c model before you can upload attachments.  The ParentId on the Attachment model must be set to upload an attachment.  There are some ways to work around this with JavaScript.

Thanks,

Bill
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
Thanks Bill.  I have changed to the ParentId and I do create the record. 





I made the changes.  However, it looks like the ParentId is 15 digits long and the ID of  A_Temp_Add_Task_CR__c  is 18 digits.  Is this a problem?  If so, how to resolve
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Bill,

It won't be a problem.  Skuid will handle pulling the attachments using the 15 digit Id.

In your attachment model (Attachment_CR) change the Condition State to 'Filterable Default On'.  Add a model action to your A_Temp_Add_Task_CR__c model.  The initiating action is 'Model Saved'.  Add 2 actions:
  1. Activate and Set value of Model Condition of the ParentId on your Attachment_CR model.  Set the value to {{$Model.A_Temp_Add_Task_CR__c.data.0.Id}}.  Make sure that you have the 'Id' field returned in the A_Temp_Add_Task_CR__c model.
  2. Query the Attachment_CR model.
This will enable any attachments you upload to be 'linked' to the newly created record in A_Temp_Add_Task_CR__c.

Thanks,

Bill
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
Thanks Bill,

I believe I have set all as suggested.  The table shows blank as it should but no new record shows in the table below.  Here is a video to show how it does not work
https://drive.google.com/file/d/0B409lhd9sYDcaVMwRTNZem1Jc3M/view
Cheers,
Bill
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Bill,

I just tried this in my dev org.  I was able to get it working the way I was thinking it could work.  I think the only thing I did differently is that did not load the attachment model on page load and set the parentid condition to default off.

Here is the XML of the page I tried this on.  Maybe it can help you figure out what changes to make.  This page creates a new task.  It only uses standard objects.  You will be fine to install it wherever.

Thanks,

Bill

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Task">
   <models>
      <model id="CurrentUser" limit="1" query="true" createrowifnonefound="false" adapter="" type="" sobject="User">
         <fields>
            <field id="Id"/>
         </fields>
         <conditions>
            <condition type="userinfo" value="" field="Id" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
         </conditions>
         <actions/>
      </model>
      <model id="Task" limit="1" query="false" createrowifnonefound="true" sobject="Task" adapter="" type="">
         <fields>
            <field id="Subject"/>
            <field id="Description"/>
            <field id="ActivityDate"/>
            <field id="WhoId"/>
            <field id="Who.Name"/>
            <field id="Id"/>
         </fields>
         <conditions>
            <condition type="fieldvalue" value="TODAY" enclosevalueinquotes="false" field="ActivityDate"/>
         </conditions>
         <actions>
            <action>
               <actions>
                  <action type="setCondition" model="Attachment" condition="ParentId" value="{{Id}}"/>
                  <action type="requeryModel" model="Attachment" behavior="standard"/>
               </actions>
               <events>
                  <event>models.saved</event>
               </events>
            </action>
         </actions>
      </model>
      <model id="NewContact" limit="1" query="false" createrowifnonefound="true" adapter="" type="" sobject="Contact" doclone="no">
         <fields>
            <field id="FirstName"/>
            <field id="LastName"/>
            <field id="Phone"/>
            <field id="Name"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
      <model id="Attachment" limit="20" query="false" createrowifnonefound="false" adapter="" type="" sobject="Attachment">
         <fields>
            <field id="Body"/>
            <field id="Description"/>
            <field id="Name"/>
            <field id="ParentId"/>
            <field id="Parent.Name"/>
            <field id="CreatedDate"/>
         </fields>
         <conditions>
            <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="ParentId" state="filterableoff" inactive="true" name="ParentId"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Task" uniqueid="sk-EWg8t-72">
         <maintitle>
            <template>New {{Model.label}}</template>
         </maintitle>
         <subtitle>
            <template>{{Model.labelPlural}}</template>
         </subtitle>
         <actions>
            <action type="popup" label="Create New Contact" icon="sk-icon-contact">
               <popup title="New Popup" width="90%">
                  <components>
                     <pagetitle model="NewContact" uniqueid="sk-1z6FUj-146">
                        <maintitle>
                           <template>{{Name}}</template>
                        </maintitle>
                        <subtitle>
                           <template>{{Model.label}}</template>
                        </subtitle>
                        <actions>
                           <action type="multi" label="Save" icon="sk-icon-save">
                              <actions>
                                 <action type="blockUI"/>
                                 <action type="save">
                                    <models>
                                       <model>NewContact</model>
                                    </models>
                                 </action>
                                 <action type="updateRow" fieldmodel="Task" field="WhoId" enclosevalueinquotes="true" value="{{$Model.NewContact.data.0.Id}}"/>
                                 <action type="updateRow" fieldmodel="Task" field="Who.Name" enclosevalueinquotes="true" value="{{$Model.NewContact.data.0.Name}}"/>
                                 <action type="closeTopmostPopup"/>
                                 <action type="unblockUI"/>
                              </actions>
                           </action>
                           <action type="multi" label="Cancel" icon="sk-icon-cancel">
                              <actions>
                                 <action type="cancel">
                                    <models>
                                       <model>NewContact</model>
                                    </models>
                                 </action>
                                 <action type="closeTopmostPopup"/>
                              </actions>
                           </action>
                        </actions>
                     </pagetitle>
                     <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="NewContact" buttonposition="" uniqueid="sk-1z6GmT-149" mode="edit">
                        <columns>
                           <column width="33.3%">
                              <sections>
                                 <section title="Section A" collapsible="no">
                                    <fields>
                                       <field id="FirstName"/>
                                    </fields>
                                 </section>
                              </sections>
                           </column>
                           <column width="33.3%">
                              <sections>
                                 <section title="Section B" collapsible="no">
                                    <fields>
                                       <field id="LastName"/>
                                    </fields>
                                 </section>
                              </sections>
                           </column>
                           <column width="33.3%">
                              <sections>
                                 <section title="New Section" collapsible="no">
                                    <fields>
                                       <field id="Phone" valuehalign="" type=""/>
                                    </fields>
                                 </section>
                              </sections>
                           </column>
                        </columns>
                     </basicfieldeditor>
                  </components>
               </popup>
            </action>
            <action type="savecancel" afterCancel="" afterSave="" rollbackonanyerror="true" window="self"/>
         </actions>
      </pagetitle>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Task" mode="edit" uniqueid="sk-EWg8t-73">
         <columns>
            <column width="50%">
               <sections>
                  <section title="Basics" collapsible="no">
                     <fields>
                        <field id="Subject"/>
                        <field id="ActivityDate" valuehalign="" type="" required="true"/>
                     </fields>
                  </section>
               </sections>
            </column>
            <column width="50%">
               <sections>
                  <section title="Additional Info" collapsible="no">
                     <fields>
                        <field id="WhoId" valuehalign="" type=""/>
                        <field id="Description"/>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
      <file storeas="record" displayas="filename" uniqueid="sk-2hUsDm-189" model="Task" label="Upload file to task"/>
      <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Attachment" buttonposition="" mode="read" uniqueid="sk-2hUhhz-162">
         <fields>
            <field id="Name"/>
            <field id="CreatedDate"/>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
         </rowactions>
         <massactions usefirstitemasdefault="true">
            <action type="massupdate"/>
            <action type="massdelete"/>
         </massactions>
         <views>
            <view type="standard"/>
         </views>
      </skootable>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript>
         <jsitem location="inline" name="newInlineJSClearDate" cachelocation="false" url="">(function(skuid){
    var $ = skuid.$;
    $(document.body).one('pageload',function(){
        var myModel = skuid.model.getModel('Task');
        //var myComponent = skuid.component.getById('MyComponentUniqueId');
        var row = myModel.getFirstRow();
        myModel.updateRow(row, {ActivityDate:''});
    });
})(skuid);</jsitem>
      </javascript>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
(Edited)