How to have drawer filter to show record based on ID field from related row

I have a simple table with drawers on each row and the setup is that the row model is based on “ProcessInstanceWorkItem” and I have filtered it to show only those related to cases and some other filters to make them relevant, but the main thing to note is that the row and drawer are not related objects, it’s related via a polymorphic field like the relation tasks make with almost any object.

What I want to do is when I click on the drawer (or it can load the rows up on page load, the amount of rows will be small) I want it to take the Case ID from the row and update the drawer filter (model in drawer is “Cases”) so all the fields displayed show data for the relevant case.

I tried to accomplish this by adding a condition on the drawer as shown in image:
Screen Shot 2021-12-15 at 5.10.00 PM

That didn’t work, when I click the drawer nothing happens and it never loads the drawer/fields.

I also tried an action on page load to update the condition based on another model field and that worked for the first row but then all the rest of the drawers on row 2+ had the same case value from row 1.

I am brand new to Skuid so this may be very easy or maybe not but I’m hoping to get some ideas as this is the main blocker before I can do some really cool stuff with this app I’m building. I’m trying to fix Salesforce approvals and give my users much more information than just the related object’s name and date approval was requested.

Skuid Info:
We are on Boston
This app is built on v2
I have admin rights in SFDC
I know SFDC pretty well, but Skuid is new to me, to build. Been using it for years.

Hello!

There are a couple of ways this can be tackled (depending on when you’d like to load the drawer content). I believe this link has a very similar example written out in detail. Here are some basic instructions using your information.

If loading all Cases on page load:

  • In the page composer – If you click on one of the data components within the drawer, you will see the option to add a context condition. This will allow you to define the context for the record which you want to show in the drawer.
  • I believe the context here would be something like Id (of the case model) is the ProcessInstance.TargetObject.Id of the “ProcessInstanceWorkItem” model.

If loading on click of drawer:

  • Follow the same steps above to add the context condition to the components inside the drawer.
  • Add a condition to your case model that is: “Case records where Id is Single specified value” and then leave the value blank.
  • Set the state of the condition to “Filterable default off”
  • If you select your drawer icon in the table builder, you will be able to add “Before load actions”
  • Add 1 action to “Activate/set model condition” and set the value of your condition as {{ProcessInstance.TargetObject.Id}}
  • Add another action to query your Case Model. On this action, be sure and select “Get more - Merge in new rows with old”.
  • This will allow you to continue to add rows to the model so you do not have to reload them every-time you click on the particular row.
1 Like

Hi Clark,

Thank you for your reply. I tried the first part, for all to load at once and it works for the first row but all the rows after that are blank. It expands a slight bit of white space but nothing renders. See screenshots:


Also, the link you showed is for when there is a reference field that links the two objects. I wasn’t able to figure how to do mine based on that but I really appreciate you digging up the help doc.

The second set of instructions made me feel like we got close but now each section expands but it still has the context of the first row only. Any suggestions? Here are a bunch of screenshots to help in case you notice something my eyes missed. Apologies for the poor drawing to get rid of names and IDs I didn’t want shared on the web.

Do you mind sending screenshots of the context conditions you have set up on the components in the drawer? I suspect that might be the culprit here.

1 Like

Here is a screenshot of the context for the form inside the drawer. The drawer is simple and this is all that is inside there. I tried to take the screenshot to show some of the index for that part as well as the context. Happy to share more if you need it. Really appreciate you both helping me out!

Well… you have me stumped. Everything looks correct from the screenshots you’ve included.
I went ahead and tried to recreate the functionality on my end, and was able to get the right data to load in the drawers, so I’ll attach the page XML here so that you can compare with your page to see what the difference might be.

<skuid__page unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
	<models>
		<model id="PIWI" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="ProcessInstanceWorkitem">
			<fields>
				<field id="ProcessInstanceId"/>
				<field id="ProcessInstance.TargetObjectId"/>
				<field id="ProcessInstance.TargetObject.Name"/>
				<field id="ProcessInstance.TargetObject.Type"/>
				<field id="ProcessInstance.TargetObject.Id"/>
			</fields>
			<conditions>
				<condition type="fieldvalue" value="Case" enclosevalueinquotes="true" field="ProcessInstance.TargetObject.Type"/>
			</conditions>
			<actions/>
		</model>
		<model id="case" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Case">
			<fields>
				<field id="RecordTypeId"/>
				<field id="RecordType.Name"/>
				<field id="Type"/>
				<field id="CaseNumber"/>
				<field id="Id"/>
			</fields>
			<conditions>
				<condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Id" clientorserver="server" state="filterableoff" inactive="true" name="Id"/>
			</conditions>
			<actions/>
		</model>
	</models>
	<components>
		<skuid__table allowColumnFreezing="dragDrop" model="PIWI" uniqueid="sk-3UDL-38213" mode="read" showSaveCancel="true" pageSize="10" enableDrawers="true">
			<fields>
				<field id="ProcessInstanceId" uniqueid="fi-3UDL-38869"/>
				<field id="ProcessInstance.TargetObjectId" uniqueid="fi-3UDL-38871"/>
				<field id="ProcessInstance.TargetObject.Name" uniqueid="fi-3UDL-38872"/>
				<field id="ProcessInstance.TargetObject.Type" uniqueid="fi-3UDL-38873"/>
				<field id="ProcessInstance.TargetObject.Id" uniqueid="fi-3UDL-38874"/>
			</fields>
			<filtering enableSearch="false"/>
			<actions/>
			<rowActions/>
			<massActions/>
			<exportProperties useTableColumns="true"/>
			<sorting enable="false"/>
			<drawer>
				<beforeLoad>
					<action type="updateCondition" model="case" behavior="set" condition="Id" valuesource="fieldvalue" value="{{ProcessInstance.TargetObject.Id}}"/>
					<action type="requeryModels" behavior="loadmore">
						<models>
							<model>case</model>
						</models>
					</action>
				</beforeLoad>
				<components>
					<skuid__form showErrorsInline="true" model="case" uniqueid="sk-3UD_-51493" mode="read">
						<columns>
							<column>
								<sections>
									<section title="New Section">
										<fields>
											<skuid__field id="CaseNumber" uniqueId="sk-3UE1-53098"/>
											<skuid__field id="Type" uniqueId="sk-3UE1-53111"/>
										</fields>
									</section>
								</sections>
							</column>
						</columns>
						<conditions>
							<condition type="contextrow" field="Id" mergefield="ProcessInstance.TargetObject.Id" operator="="/>
						</conditions>
					</skuid__form>
				</components>
			</drawer>
		</skuid__table>
	</components>
	<resources>
		<labels/>
		<javascript/>
		<css/>
		<actionsequences/>
	</resources>
	<styles>
		<styleitem type="background" bgtype="none"/>
	</styles>
</skuid__page>
1 Like

I started running down the XML to compare and all was well until I hit my related case model and the conditions and then I got lost as to if the differences are meaningful and could be why they don’t work the same or not. This is all really new to me and while I get some of the XML and what it means, some of it is like a foreign language to me. I appreciate all the help so far and if you don’t have time to look this over, I 100% understand but I’ll post it in case you or anyone can spot my issue(s).

Note: this XML has a bunch of other stuff I didn’t talk about so I’ll point out the model names that relates to the issue I’m having. I’ll eventually be doing similar things for the other models (Opportunities, Contracts, etc.) after I figure this out for the case approval model.

So the Parent table/model is called “NewModelCasePIWI” and the model in the drawer is called “RelatedCase” and all the other stuff can be ignored unless you think something I did in those models if affecting these for whatever reason.

<skuid__page unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
<models>
<model id="All_My_Approvals" limit="40" query="true" createrowifnonefound="false" datasource="salesforce" sobject="ProcessInstanceWorkitem">
	<fields>
		<field id="Actor.Name"/>
		<field id="CreatedBy.Name"/>
		<field id="CreatedDate"/>
		<field id="ElapsedTimeInHours"/>
		<field id="ProcessInstance.Status"/>
		<field id="ProcessInstance.TargetObject.Name"/>
		<field id="ProcessInstance.TargetObject.Type"/>
		<field id="ProcessInstance.TargetObject.Id"/>
		<field id="ProcessInstance.ProcessDefinition.Name"/>
	</fields>
	<conditions>
		<condition type="userinfo" value="" field="ActorId" fieldtargetobjects="Group,User" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
		<condition type="fieldvalue" value="Tapjoy_Knowledge__ka" enclosevalueinquotes="true" field="ProcessInstance.TargetObject.Type" operator="!="/>
	</conditions>
	<actions/>
</model>
<model id="NewModelCasePIWI" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="ProcessInstanceWorkitem">
	<fields>
		<field id="ActorId"/>
		<field id="Actor.Name"/>
		<field id="CreatedDate"/>
		<field id="Id"/>
		<field id="ProcessInstanceId"/>
		<field id="ProcessInstance.ProcessDefinitionId"/>
		<field id="ProcessInstance.ProcessDefinition.Name"/>
		<field id="ProcessInstance.Id"/>
		<field id="ProcessInstance.TargetObject.Id"/>
		<field id="ProcessInstance.TargetObject.Name"/>
		<field id="ProcessInstance.TargetObject.Type"/>
	</fields>
	<conditions>
		<condition type="fieldvalue" value="Case" enclosevalueinquotes="true" field="ProcessInstance.TargetObject.Type"/>
		<condition type="userinfo" value="" field="ActorId" fieldtargetobjects="Group,User" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
	</conditions>
	<actions/>
</model>
<model id="NewModelContractPIWI" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="ProcessInstanceWorkitem">
	<fields>
		<field id="ActorId"/>
		<field id="Actor.Name"/>
		<field id="CreatedDate"/>
		<field id="ProcessInstanceId"/>
		<field id="ProcessInstance.Status"/>
		<field id="ProcessInstance.TargetObjectId"/>
		<field id="ProcessInstance.TargetObject.Name"/>
		<field id="ProcessInstance.TargetObject.Type"/>
	</fields>
	<conditions>
		<condition type="fieldvalue" value="Contract" enclosevalueinquotes="true" field="ProcessInstance.TargetObject.Type"/>
		<condition type="userinfo" value="" field="ActorId" fieldtargetobjects="Group,User" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
	</conditions>
	<actions/>
</model>
<model id="NewOppModelPIWI" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="ProcessInstanceWorkitem">
	<fields>
		<field id="ProcessInstance.TargetObject.Type"/>
		<field id="ProcessInstance.TargetObject.Id"/>
		<field id="Actor.Name"/>
		<field id="CreatedDate"/>
		<field id="ProcessInstanceId"/>
		<field id="ProcessInstance.ProcessDefinition.Name"/>
		<field id="ProcessInstance.Status"/>
		<field id="ProcessInstance.TargetObjectId"/>
		<field id="ProcessInstance.TargetObject.Name"/>
	</fields>
	<conditions>
		<condition type="fieldvalue" value="Opportunity" enclosevalueinquotes="true" field="ProcessInstance.TargetObject.Type"/>
		<condition type="userinfo" value="" field="ActorId" fieldtargetobjects="Group,User" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
	</conditions>
	<actions/>
</model>
<model id="RelatedCase" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Case">
	<fields>
		<field id="RecordTypeId"/>
		<field id="RecordType.Name"/>
		<field id="Account__c"/>
		<field id="Id"/>
		<field id="CaseNumber"/>
		<field id="Case_Owner__c"/>
		<field id="Status"/>
		<field id="Account.RecordType.Name"/>
		<field id="Account.Owner.Name"/>
	</fields>
	<conditions>
		<condition type="fieldvalue" value="" field="Id" operator="=" mergefield="ProcessInstance.TargetObject.Id" novaluebehavior="deactivate" enclosevalueinquotes="true" clientorserver="server" state="filterableon" inactive="false" name="Id"/>
	</conditions>
	<actions/>
</model>
</models>
<components>
<skuid__tabContainer uniqueid="sk-2rw0-2442">
	<tabs>
		<skuid__tabPanel name="All Approvals" icon="sk-webicon-icons8-win10:todo_list">
			<components>
				<skuid__table allowColumnFreezing="dragDrop" uniqueid="sk-2rwz-70327" mode="read" model="All_My_Approvals">
					<fields>
						<field id="Actor.Name" label="Approver" uniqueid="fi-2r-h-84036"/>
						<field id="CreatedBy.Name" label="Submitted By" uniqueid="fi-2r-h-84037"/>
						<field id="CreatedDate" uniqueid="fi-2s17-89954"/>
						<field id="ElapsedTimeInHours" horizontalAlignment="right" label="Hours in Queue" decimalPlaces="1" uniqueid="fi-2s17-89955"/>
						<field id="ProcessInstance.Status" uniqueid="fi-2s17-89956"/>
						<field id="ProcessInstance.TargetObject.Name" label="Record To Be Approved" uniqueid="fi-2s17-89957"/>
						<field id="ProcessInstance.TargetObject.Type" label="Object Type" uniqueid="fi-2s17-89958"/>
					</fields>
					<filtering enableSearch="false"/>
					<rowActions/>
					<massActions/>
				</skuid__table>
			</components>
			<onInitialShowActions/>
			<onShowActions/>
			<renderConditions logictype="and"/>
		</skuid__tabPanel>
		<skuid__tabPanel name="Case Approvals" icon="sk-webicon-ionicons:ios-briefcase">
			<components>
				<skuid__table allowColumnFreezing="dragDrop" model="NewModelCasePIWI" uniqueid="sk-2xN2-378680" mode="read" pageSize="10" enableDrawers="true">
					<fields>
						<field id="Actor.Name" uniqueid="fi-2xNB-381025"/>
						<field id="CreatedDate" uniqueid="fi-2xNB-381026"/>
						<field id="Id" uniqueid="fi-2xNB-381027"/>
						<field id="ProcessInstance.TargetObject.Name" uniqueid="fi-2xNB-381028"/>
						<field id="ProcessInstance.TargetObject.Type" uniqueid="fi-2xNB-381029"/>
						<field id="ProcessInstance.TargetObject.Id" uniqueid="fi-360T-28444" label="ProcessInstance.TargetObject.Id"/>
					</fields>
					<filtering enableSearch="false"/>
					<rowActions/>
					<massActions/>
					<drawer>
						<components>
							<skuid__form showErrorsInline="true" model="RelatedCase" uniqueid="sk-2xZU-399526" mode="read">
								<sections>
									<section title="Case#{{CaseNumber}}">
										<rows>
											<row>
												<fields>
													<skuid__field id="Case_Owner__c" uniqueId="sk-2xb--414544"/>
													<skuid__field id="Status" uniqueId="sk-2xb--414549"/>
													<skuid__field id="RecordType.Name" uniqueId="sk-2xb--414554" label="Case Record Type"/>
												</fields>
											</row>
											<row>
												<fields>
													<skuid__field id="Account__c" uniqueId="sk-2xb--414539" label="Account Name"/>
													<skuid__field id="Account.RecordType.Name" uniqueId="sk-2xcf-421134" label="Account Type"/>
													<skuid__field id="Account.Owner.Name" uniqueId="sk-2xcf-422341" label="Account Owner">
														<renderConditions logictype="and" onhidedatabehavior="keep"/>
														<enableConditions/>
														<styleVariantConditions/>
													</skuid__field>
												</fields>
											</row>
										</rows>
										<renderConditions logictype="and"/>
									</section>
								</sections>
								<styles>
									<spacing/>
								</styles>
								<renderConditions logictype="and"/>
								<styleVariantConditions/>
								<conditions>
									<condition type="contextrow" field="Id" mergefield="ProcessInstance.TargetObject.Id" operator="="/>
								</conditions>
							</skuid__form>
						</components>
						<beforeLoad>
							<action type="setCondition" model="RelatedCase" valuesource="fieldvalue" condition="Id" value="{{ProcessInstance.TargetObject.Id}}" sourcemodel="NewModelCasePIWI" sourcefield="ProcessInstance.TargetObject.Id"/>
							<action type="requeryModel" model="RelatedCase" behavior="loadmore"/>
						</beforeLoad>
					</drawer>
					<styles>
						<spacing/>
					</styles>
					<renderConditions logictype="and"/>
					<styleVariantConditions/>
				</skuid__table>
			</components>
		</skuid__tabPanel>
		<skuid__tabPanel name="Opportunity Approvals" icon="sk-webicon-material-icons:attach_money">
			<components>
				<skuid__table allowColumnFreezing="dragDrop" model="NewOppModelPIWI" uniqueid="sk-2xJo-345020" mode="read">
					<fields>
						<field id="ProcessInstance.TargetObject.Id" uniqueid="fi-2xKC-347194"/>
						<field id="ProcessInstance.TargetObject.Type" uniqueid="fi-2xKC-347195"/>
						<field id="Actor.Name" uniqueid="fi-2xLO-356161"/>
						<field id="CreatedDate" uniqueid="fi-2xLO-356162"/>
						<field id="ProcessInstance.ProcessDefinition.Name" label="Approval Name" uniqueid="fi-2xLO-356163"/>
						<field id="ProcessInstance.Status" uniqueid="fi-2xLO-356164"/>
						<field id="ProcessInstance.TargetObject.Type" uniqueid="fi-2xLO-356165"/>
						<field id="ProcessInstance.TargetObject.Name" uniqueid="fi-2xLW-357671"/>
					</fields>
					<filtering enableSearch="false"/>
					<rowActions/>
					<massActions/>
				</skuid__table>
			</components>
		</skuid__tabPanel>
		<skuid__tabPanel name="Contract Approvals" icon="sk-webicon-font-awesome:pencil-square">
			<components>
				<skuid__table allowColumnFreezing="dragDrop" model="NewModelContractPIWI" uniqueid="sk-2sHM-95218" mode="read">
					<fields>
						<field id="Actor.Name"/>
						<field id="CreatedDate"/>
						<field id="ProcessInstance.TargetObject.Type"/>
						<field id="ProcessInstance.TargetObject.Name"/>
					</fields>
					<filtering enableSearch="false"/>
					<rowActions/>
					<massActions/>
				</skuid__table>
			</components>
		</skuid__tabPanel>
	</tabs>
</skuid__tabContainer>
</components>
<resources>
	<labels/>
	<javascript/>
	<css/>
	<actionsequences>
<actionsequence id="8d82f586-f06d-4d9c-9d05-ad3d2540d822" label="Update Drawer">
							<actions>
<action type="setCondition" model="RelatedCase" valuesource="modelmerge" sourcemodel="NewModelCasePIWI" sourcefield="ProcessInstance.TargetObject.Id" value="{{ProcessInstance.TargetObject.Id}}"/>
<action type="save">
	<models>
		<model>NewModelCasePIWI</model>
	</models>
</action>
</actions>
							<description/>
						</actionsequence>
</actionsequences>
</resources>
<styles>
	<styleitem type="background" bgtype="none"/>
</styles>
</skuid__page>

The plot thickens. I created a page using the xml you provided in an org running Boston (13.0.32.0) and it worked as expected - each drawer shows the correct case number associated with that row, and your setup looks correct.

Which specific version of Boston are you running (current version info is available at Skuid Settings > About Skuid)?

1 Like

ahh looks like we are using Boston (13.0.11.0) so not as up to date as yours. I have a developer in this sandbox that also has projects so I’ll ask him if it’s ok to update. I’m also thinking, sometimes when I run into weird what I call ghost issues and I just recreate in a new project it sometimes works, kind of like the old power off and on router/computer/etc “trick”. I’m going to try to recreate this in a new project and then if that doesn’t help, update the version (if dev says it’s ok).

Thanks again!