"In context" not working on a button within a drawer

  • 1
  • Problem
  • Updated 2 years ago
  • Solved
Please help! I am having trouble getting the 'In context' to work on a button within a drawer. I have tried the 'button set' component and the 'page title' component but neither seem to be working. The 'in context' that I am trying to access is just the record ID for the row I am on - nothing fancy.  (I am using Brooklyn 9.3.1)  

For both Button Set and Page Title components: Within the component configurations I set the Model to the same model that the table uses & I set the context condition to read "Id of record = Id of row in context"
I then created a button in each component and used the name of the record as the label on the button (to see what was pulling through).  On the Button component the label listed the name of the 1st record on the table, the Page Title component correctly displayed the row's name. 

Within the action framework I was not able to get either component to work correctly.  For each button, I set up an action framework that creates a new child record and assigns the record id of the row to the correct parent lookup field.  For both buttons, the first row in the table is always used as the parent.

Some troubleshooting I've done: 
Child record model (we'll call the model NewChild) is configured to not load data on page load and does not create a default row
Whenever the button is clicked, the action framework removes all rows from NewChild then creates a new row.

I have tried to set a filterable condition on the NewChild model for the parent lookup where I used the Id from the parent model
Another trial where I set a filterable condition to a 'single specified value' but left the value blank and then activated and set it from the button.
I have also removed the condition entirely and tried to use the 'update row' action to set the parent Id.

I can't figure out what else might be the problem.  It seems that I didn't have this problem before brooklyn, but I cannot remember for sure. Has anybody experienced this on Brooklyn or see something that I am missing? 
Many thanks!!
Photo of susan.nordquist

susan.nordquist

  • 354 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Susan,

Right now there is an issue with button sets not respecting context, but our developers are aware of it and we'll let you know when a fix is released. Buttons in page titles, though, should be fine and what you're doing should work. Kind of silly, but can you double check that you have the id field included in your parent model?

Thanks!
Amy
Photo of susan.nordquist

susan.nordquist

  • 354 Points 250 badge 2x thumb
Hi Amy,
Thanks for the reply! I ended up uninstalling Brooklyn and reinstalling the latest version on the app exchange. It works as expected now.
Thanks,
Susan
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Susan,

I'm sorry you had to do that, but I'm glad you got it sorted out! I'll let you know when the button set issue is fixed, and I hope you'll give Brooklyn another chance after that, as it has some neat features that aren't present in Rockaway.

Thanks!
Amy
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Hi Skuid Community~

Thank you for your patience as we addressed this bug. This issue has been resolved in the
Brooklyn Update 1 which is now available from the Skuid Releases page.

As a reminder, Salesforce does NOT allow reverting back to prior versions of managed packages. Skuid always recommends installing new versions in a non-business critical sandbox environment to test all mission critical functionality before installing into a production environment. We also recommend that you update out of date themes when you upgrade.

Thanks!
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Hello, I've just updated to the latest version of Skuid, but I'm still getting this issue. I've changed the model to merge data, but it's ignoring the "in context" action. Help!!
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Laura,

Can you give some more details around what you're trying to do? For instance, are you showing data from the same model in a drawer or data from a different model? One thing to check is that your model(s) have their Id's included in them. In case you hadn't heard of it, this tutorial could also be helpful for you.
 
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Hi Amy, I have a table of data, from a model called EPP_Projects, in our customer community.

There is then a drawer that opens, and activates another model called EPP_Project_Single, with additional data around the project. This works fine and displays the correct information, through the Activate & Set condition function. 

I want the user of the community to be able to click on a button, that says "I want to know more" - this then creates a new record (different object), pulling information from "EPP_Project_Single" as well as info on the running user. The button works most of the time if I use "Standard - completely replace data) on the query model for the draw, but then breaks if more than one draw is open or a draw is opened, closed & opened again.

Therefore I am trying to fix the bugs surrounding this by using context on the button to link to EPP_Project_Single, and having the model set to "Get More - Merge in New Rows", but everytime I do this, the button ignores the content & just adds data from the first record in the model each time, regardless of the draw/row it is in.
Photo of Sean Willerford

Sean Willerford

  • 300 Points 250 badge 2x thumb
I'm also having this issue before AND after updating to Brooklyn 9.5.4. I have a table of data with a drawer, and a page title in that drawer. There is a page title button that has a URL redirect that sends us to our document generation software; that URL includes "?Id={{Id}}". 

When I click the button, it redirects fine, but no matter which record I have open / click on, Skuid includes the ID of the first row of that model instead of the ID of the row in context. This happens no matter what drawers I have open - I've tried all the variations.

Interestingly, I checked the model to see if the record ID was included, and it wasn't. I included it and the issue is still exactly the same.
(Edited)
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Laura and Sean,

I think that both of you guys' situations should be able to work (there shouldn't be any issues blocking you). It sounds like you both might need context conditions on your button sets / page titles so that it pulls the right data or redirects to the right Id. The setup for drawers is pretty particular, though, so I'll go through what I did to get my setup working and hopefully that will help you.

I have a main table looking at accounts, and then a drawer to show the contacts for each account. For the Accounts model, the only gotcha is to make sure you include the Account Id (and any other fields you want to show). For the ContactDrawer model, though, there's a pretty specific setup. Start by making sure to include the Contact Id, and any other fields you want access to. Next, make sure it's not loading on page load and has a filterable default off condition for Account Id - 



Then, on my page I have an Account table with a drawer action. For the drawer to work properly,  you need to set Before Load Actions on it:



(The Query Model action needs to be "Get More - Merge in new Rows with old")

AND all the components in the drawer need context conditions (if you want them to interact with data in the drawer). For example, here's the context condition I set on the table of contacts:

 

Now, let me explain why you need to set the condition to "get more" AND have context conditions (to me, at first, it seemed like overkill). The drawer model starts empty, and as you open drawers the before load action on the drawer loads the appropriate data into the model (in this case contacts based on which account you look at). The "get more" part of the querying allows you to have multiple drawers open. However, without the context conditions the table would show all contacts you've accumulated up to this point no matter which account drawer you open, and the list would keep growing as you opened more drawers. The context condition limits which contacts you see under which account, so that it's always appropriately paired. You can also see this information at this tutorial, in case you want to find it again (or want more screenshots than I did :) )
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Here's the XML for my sample drawer page. Because I show contacts under an account, my New Task button and Redirect button default to the first contact under that Account (but you could have those actions as row actions if you wanted to be able to do those actions for any contact under an account):

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="AccountContactRole">
    <models>
        <model id="Account" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Account">
            <fields>
                <field id="Name"/>
                <field id="Industry"/>
                <field id="Id"/>
                <field id="Phone"/>
                <field id="Rating"/>
                <field id="AnnualRevenue"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="DrawerContacts" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
            <fields>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="Id"/>
                <field id="FirstName"/>
                <field id="LastName"/>
                <field id="Name"/>
                <field id="Age__c"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="AccountId" state="filterableoff" inactive="true" name="AccountId"/>
            </conditions>
            <actions/>
        </model>
        <model id="NewTask" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Task">
            <fields>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="WhoId"/>
                <field id="Who.Name"/>
                <field id="Subject"/>
                <field id="OwnerId"/>
                <field id="Owner.Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <grid uniqueid="sk-3EaUjO-225">
            <divisions>
                <division behavior="flex" minwidth="100px" ratio="1">
                    <components>
                        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Account" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-39NeR1-137">
                            <fields>
                                <field id="Name" hideable="true" uniqueid="fi-39NiSa-157"/>
                                <field id="Industry" hideable="true" uniqueid="fi-39NiSa-158" valuehalign="" type=""/>
                                <field id="Phone" hideable="true" uniqueid="fi-39Obhq-100" valuehalign="" type=""/>
                            </fields>
                            <rowactions>
                                <action type="edit"/>
                                <action type="delete"/>
                                <action type="drawer" label="Run multiple actions" icon="sk-icon-go-to-full-detail-page">
                                    <drawer title="Drawer Area" width="90%" closehandle="true">
                                        <components>
                                            <buttonset model="DrawerContacts" uniqueid="sk-3EbbPf-391">
                                                <buttons>
                                                    <button type="multi" label="New Task">
                                                        <actions>
                                                            <action type="createRow" model="NewTask" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
                                                                <defaults>
                                                                    <default type="fieldvalue" field="WhoId" enclosevalueinquotes="true" value="{{Id}}"/>
                                                                </defaults>
                                                            </action>
                                                            <action type="showPopup">
                                                                <popup title="New Popup" width="90%">
                                                                    <components>
                                                                        <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="NewTask" buttonposition="" uniqueid="sk-3Ebzv--486" mode="edit">
                                                                            <columns>
                                                                                <column width="50%">
                                                                                    <sections>
                                                                                        <section title="Section A" collapsible="no">
                                                                                            <fields>
                                                                                                <field id="AccountId" uniqueid="fi-3EjQxb-236"/>
                                                                                                <field id="WhoId" uniqueid="fi-3EjQxb-237"/>
                                                                                                <field id="Subject" uniqueid="fi-3EjQxb-238"/>
                                                                                                <field id="OwnerId" uniqueid="fi-3EjQxb-239"/>
                                                                                            </fields>
                                                                                        </section>
                                                                                    </sections>
                                                                                </column>
                                                                                <column width="50%">
                                                                                    <sections>
                                                                                        <section title="Section B">
                                                                                            <fields/>
                                                                                        </section>
                                                                                    </sections>
                                                                                </column>
                                                                            </columns>
                                                                        </basicfieldeditor>
                                                                    </components>
                                                                </popup>
                                                            </action>
                                                        </actions>
                                                    </button>
                                                    <button type="redirect" label="Redirect to URL" window="blank" url="/{{Id}}"/>
                                                </buttons>
                                                <conditions>
                                                    <condition type="contextrow" field="AccountId" mergefield="Id" operator="="/>
                                                </conditions>
                                            </buttonset>
                                            <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="DrawerContacts" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-3Eao5Y-289">
                                                <fields>
                                                    <field id="AccountId" hideable="true" uniqueid="fi-3Eaqv1-303"/>
                                                    <field id="FirstName" hideable="true" uniqueid="fi-3Eaqv1-304"/>
                                                    <field id="LastName" hideable="true" uniqueid="fi-3Eaqv2-305"/>
                                                </fields>
                                                <rowactions>
                                                    <action type="edit"/>
                                                    <action type="delete"/>
                                                    <action type="redirect" label="Redirect" icon="sk-icon-arrow-right" window="blank" url="/{{Id}}"/>
                                                </rowactions>
                                                <massactions usefirstitemasdefault="true">
                                                    <action type="massupdate"/>
                                                    <action type="massdelete"/>
                                                </massactions>
                                                <views>
                                                    <view type="standard"/>
                                                </views>
                                                <conditions>
                                                    <condition type="contextrow" field="AccountId" mergefield="Id" operator="="/>
                                                </conditions>
                                                <searchfields/>
                                            </skootable>
                                        </components>
                                        <beforeload>
                                            <action type="setCondition" model="DrawerContacts" condition="AccountId" value="{{Id}}"/>
                                            <action type="requeryModel" model="DrawerContacts" behavior="loadmore"/>
                                        </beforeload>
                                    </drawer>
                                </action>
                            </rowactions>
                            <massactions usefirstitemasdefault="true">
                                <action type="massupdate"/>
                                <action type="massdelete"/>
                            </massactions>
                            <views>
                                <view type="standard"/>
                            </views>
                        </skootable>
                    </components>
                </division>
                <division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
                    <components>
                        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="DrawerContacts" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-3EaWcl-240">
                            <fields>
                                <field id="AccountId" hideable="true" uniqueid="fi-3EaaMo-264" valuehalign="" type=""/>
                                <field id="FirstName" hideable="true" uniqueid="fi-3EaYwL-253"/>
                                <field id="LastName" hideable="true" uniqueid="fi-3EaYwM-254"/>
                            </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>
                </division>
            </divisions>
            <styles>
                <styleitem type="background" bgtype="none"/>
            </styles>
        </grid>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Hi Amy,

I've followed through all those steps, and my draw & models are set up correctly.

Not sure what to suggest as it's all around custom objects so won't make sense to send over XML!

Laura
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Laura,

Were you able to try copying and pasting the XML that I posted above into your org as a new page? I think I have an example of what you want to do on that page, so it might be helpful as a working example (I have a table of accounts with a drawer that shows the contacts associated with each account. I then have a button in the drawer to create a new task and show it in a popup. The new task pulls info from the contact in its drawer). Let me know if you create the page and it's not similar to what you want to do.
Photo of Sean Willerford

Sean Willerford

  • 300 Points 250 badge 2x thumb
I figured out how to fix my problem, but I believe there is still a bug. Amy, you originally noted that
I then created a button in each component and used the name of the record as the label on the button (to see what was pulling through).  On the Button component the label listed the name of the 1st record on the table, the Page Title component correctly displayed the row's name. 
I am seeing this behavior too (using buttons within the Page Title component), but only when the page title component does not have a context condition. I realized I was missing a context condition, and adding it fixed my issue.

However, there does seem to still be a bug, since without a context condition the buttons in a Page Title component are operating in a different context from the text of the Page Title component...

Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Sean,

I'm able to see what you are seeing and I'll raise it as an issue to the team. We'll let you know when this is fixed in a future release.