Table results not rendering properly based on the parent ID

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hi,

I have a custom object for change requests. So while creating a change request i want to add an attachments to the Request or even for the even for those change request which are already created should also have the attachments feature in its detail page.

In my case, from the list view of change requests we have a drawer which acts like a detail page of the Change Request form. Within this drawer, i had my file upload component and table component to attach the files and then display them in the table.

Here my issue is No matter what change request form i dive in to, i am seeing all the attachments that are saved within the change request forms object.

I have the following condition on my attachments model.



AttachmentUpload model has change request object under it.

Everything looked fine for me but still unable to filter the table results based on the Change Request Form (CRF) ID.

Can anyone tell me where am i going wrong?

Thanks.
Photo of Avinash

Avinash

  • 1,726 Points 1k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

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

On your table of Attachments within the Drawer, I think you need to set Context of the table component so that it only shows the Attachments for the Change Request whose drawer you opened.  One other thing to check is that when you query your model for Attachments you should set the Query Behavior to 'Get More - Merge...'.  rather than loading all of the records i.e. 'Standard - Completely Replace the Data'

Thanks,

Bill
Photo of Avinash

Avinash

  • 1,726 Points 1k badge 2x thumb
Hi Bill,

I already have this context condition as follows.


What i don't have is an action defined on the attachments model. But no i added the following Action



But still my table is not showing any results. When i upload an image it is saying that the upload is successful but nothing is displayed on the table(Attachments).

I don't understand where am i going wrong.

Thanks.
Photo of Bill McCullough

Bill McCullough, Champion

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

I think you are missing the Before Load Drawer Actions.  I know that your Attachment table context is off.  You need to first value to be 'ParentId'.

Put this page into your org.  It's based on Tasks with their related Attachments.  It does not have any custom fields. It demonstrates what I think you are trying to do.  You can then replicate the setup in your page.

Thanks,

Bill

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Task">
    <models>
        <model id="Task" limit="100" query="true" createrowifnonefound="false" adapter="salesforce" service="salesforce" sobject="Task" type="" orderby="WhatId ASC">
            <fields>
                <field id="Subject"/>
                <field id="CreatedDate"/>
                <field id="WhatId"/>
                <field id="What.Name"/>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="IsArchived"/>
                <field id="CallDurationInSeconds"/>
                <field id="CallObject"/>
                <field id="CallDisposition"/>
                <field id="CallType"/>
                <field id="LastModifiedById"/>
                <field id="LastModifiedBy.Name"/>
                <field id="LastModifiedDate"/>
                <field id="Priority"/>
                <field id="Id"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="AttachmentDrawer" limit="20" query="false" createrowifnonefound="false" adapter="salesforce" service="salesforce" type="" sobject="Attachment">
            <fields>
                <field id="Body"/>
                <field id="Description"/>
                <field id="Name"/>
                <field id="ParentId"/>
                <field id="Parent.Name"/>
                <field id="IsPrivate"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="ParentId" state="filterableoff" inactive="true" name="ParentId"/>
            </conditions>
            <actions>
                <action>
                    <actions>
                        <action type="requeryModel" model="AttachmentDrawer" behavior="standard"/>
                    </actions>
                    <events>
                        <event>models.saved</event>
                    </events>
                </action>
            </actions>
        </model>
    </models>
    <components>
        <pagetitle model="Task" uniqueid="sk-7FG8C-80">
            <maintitle>
                <template>{{Model.labelPlural}}</template>
            </maintitle>
            <subtitle>
                <template>Home</template>
            </subtitle>
            <actions>
                <action type="savecancel"/>
            </actions>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="25" createrecords="true" model="Task" mode="read" uniqueid="sk-7FG8C-81" allowscrollbars="true" floatheader="true" buttonposition="" emptysearchbehavior="query" tablescrollheight="500px" freezeleftcolumns="true" columnstofreeze="1">
            <fields>
                <field id="WhatId" valuehalign="" type="" allowordering="true"/>
                <field id="Subject" allowordering="true"/>
                <field id="Priority" valuehalign="" type=""/>
                <field id="CallDurationInSeconds"/>
                <field id="CallObject"/>
                <field id="CallDisposition"/>
                <field id="CallType"/>
                <field id="LastModifiedById"/>
                <field id="LastModifiedDate"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
                <action type="drawer" label="Show Attachments" icon="sk-icon-attachments" openicon="sk-icon-close">
                    <drawer title="Drawer Area" width="90%" closehandle="true">
                        <components>
                            <file storeas="record" displayas="filename" uniqueid="sk-El4iy-321" model="Task"/>
                            <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="AttachmentDrawer" buttonposition="" mode="read" uniqueid="sk-Ek_fs-288">
                                <fields>
                                    <field id="Name" valuehalign="" type=""/>
                                    <field id="Description"/>
                                    <field id="IsPrivate"/>
                                </fields>
                                <rowactions>
                                    <action type="edit"/>
                                    <action type="delete"/>
                                </rowactions>
                                <massactions usefirstitemasdefault="true">
                                    <action type="massupdate"/>
                                    <action type="massdelete"/>
                                </massactions>
                                <views>
                                    <view type="standard"/>
                                </views>
                                <conditions>
                                    <condition type="contextrow" field="ParentId" mergefield="Id" operator="="/>
                                </conditions>
                            </skootable>
                        </components>
                        <beforeload>
                            <action type="setCondition" model="AttachmentDrawer" condition="ParentId" value="{{Id}}"/>
                            <action type="requeryModel" model="AttachmentDrawer" behavior="loadmore"/>
                        </beforeload>
                    </drawer>
                </action>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
            <searchfields/>
        </skootable>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Avinash

Avinash

  • 1,726 Points 1k badge 2x thumb
Thanks B ill.

It worked.