Display opportunities as a related list on Product2 record

  • 1
  • Question
  • Updated 2 years ago
  • Answered
  • (Edited)
Has anybody been able to display opportunity records on a product2 record as a related list? 
Photo of Glenn Daly

Glenn Daly

  • 1,270 Points 1k badge 2x thumb

Posted 2 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Done as a popup to a list of Products, but the same can be done for a Product detail page.


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
<models>
<model id="Products" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Product2">
<fields>
<field id="Name"/>
<field id="Description"/>
<field id="Id"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="Opps" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="StageName"/>
<field id="CloseDate"/>
</fields>
<conditions>
<condition type="join" value="" field="Id" operator="in" enclosevalueinquotes="true" joinobject="QuoteLineItem" joinfield="Quote.OpportunityId">
<conditions>
<condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Product2Id" state="filterableon" inactive="false" name="Product2Id"/>
</conditions>
</condition>
</conditions>
<actions/>
</model>
</models>
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Products" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-2njv91-129">
<fields>
<field id="Name" hideable="true" uniqueid="fi-2nkNx5-194"/>
<field id="Description" hideable="true" uniqueid="fi-2nkNx5-195"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
<action type="multi" label="View record details" icon="sk-icon-popup" openicon="fa-chevron-up">
<drawer title="Drawer Area" width="90%" closehandle="true">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Opps" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-2nl71J-238">
<fields>
<field id="Name" hideable="true" uniqueid="fi-2nlCPN-266" valuehalign="" type=""/>
<field id="StageName" hideable="true" uniqueid="fi-2nlCj--276" valuehalign="" type=""/>
<field id="CloseDate" hideable="true" uniqueid="fi-2nlD1c-287" valuehalign="" type=""/>
</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="Id" mergefield="Id" operator="="/>
</conditions>
</skootable>
</components>
<beforeload>
<action type="setCondition" model="Opps" condition="Product2Id" value="{{Id}}"/>
<action type="requeryModels" behavior="loadmore">
<models>
<model>Opps</model>
</models>
</action>
</beforeload>
</drawer>
<actions>
<action type="setCondition" model="Opps" condition="Product2Id" value="{{Id}}"/>
<action type="requeryModel" model="Opps" behavior="standard"/>
<action type="showPopup">
<popup width="80%" title="Viewing {{Model.label}}: {{Name}}">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Opps" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-2nlYuS-130">
<fields>
<field id="Name" hideable="true" uniqueid="fi-2nldg7-144"/>
<field id="CloseDate" hideable="true" uniqueid="fi-2nldg8-145"/>
<field id="StageName" hideable="true" uniqueid="fi-2nldg8-146"/>
</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/>
</skootable>
</components>
</popup>
</action>
</actions>
</action>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<javascript/>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>


(Edited)
Photo of Glenn Daly

Glenn Daly

  • 1,270 Points 1k badge 2x thumb
Thanks very much but I receive the following error message when trying to view records.

1. An error occurred while attempting to perform the following SOQL query: SELECT Name,StageName,CloseDate,Id FROM Opportunity WHERE (Id in (SELECT Quote.OpportunityId FROM QuoteLineItem WHERE (((Product2Id = '01t5E000000O3ALQA0'))))) LIMIT 21 Error:The inner select field 'Quote.OpportunityId' cannot have more than one level of relationships
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Darn it. Didn't try testing it. Can be done, just have to add another / query.
Photo of Glenn Daly

Glenn Daly

  • 1,270 Points 1k badge 2x thumb
Ah no problem, thanks for your help :) So do i need to add another condition in the opps model, is that what you're saying?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
This is what I'm saying. ;)


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
<models>
<model id="Products" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Product2">
<fields>
<field id="Name"/>
<field id="Description"/>
<field id="Id"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="Quotes" limit="" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Quote">
<fields>
<field id="Id"/>
<field id="OpportunityId"/>
<field id="Opportunity.Name"/>
</fields>
<conditions>
<condition type="join" value="" field="Id" operator="in" enclosevalueinquotes="true" joinobject="QuoteLineItem" joinfield="QuoteId">
<conditions>
<condition type="fieldvalue" value="" field="Product2Id" operator="=" mergefield="Id" novaluebehavior="deactivate" state="filterableon" inactive="false" name="Product2Id" enclosevalueinquotes="true"/>
</conditions>
</condition>
</conditions>
<actions/>
</model>
<model id="Opps" limit="" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="StageName"/>
<field id="CloseDate"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="Id" operator="in" model="Quotes" enclosevalueinquotes="true" mergefield="OpportunityId" novaluebehavior="noquery"/>
</conditions>
<actions/>
</model>
</models>
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Products" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-2njv91-129">
<fields>
<field id="Name" hideable="true" uniqueid="fi-2nkNx5-194"/>
<field id="Description" hideable="true" uniqueid="fi-2nkNx5-195"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
<action type="multi" label="View record details" icon="sk-icon-popup" openicon="fa-chevron-up">
<drawer title="Drawer Area" width="90%" closehandle="true">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Opps" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-2nl71J-238">
<fields>
<field id="Name" hideable="true" uniqueid="fi-2nlCPN-266" valuehalign="" type=""/>
<field id="StageName" hideable="true" uniqueid="fi-2nlCj--276" valuehalign="" type=""/>
<field id="CloseDate" hideable="true" uniqueid="fi-2nlD1c-287" valuehalign="" type=""/>
</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="Id" mergefield="Id" operator="="/>
</conditions>
</skootable>
</components>
<beforeload>
<action type="setCondition" model="Opps" condition="Product2Id" value="{{Id}}"/>
<action type="requeryModels" behavior="loadmore">
<models>
<model>Opps</model>
</models>
</action>
</beforeload>
</drawer>
<actions>
<action type="setCondition" model="Quotes" condition="Product2Id" value="{{Id}}"/>
<action type="requeryModels" model="Opps" behavior="standard">
<models>
<model>Quotes</model>
<model>Opps</model>
</models>
</action>
<action type="showPopup">
<popup width="80%" title="Viewing {{Model.label}}: {{Name}}">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Opps" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-2nlYuS-130">
<fields>
<field id="Name" hideable="true" uniqueid="fi-2nldg7-144"/>
<field id="CloseDate" hideable="true" uniqueid="fi-2nldg8-145"/>
<field id="StageName" hideable="true" uniqueid="fi-2nldg8-146"/>
</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/>
</skootable>
</components>
</popup>
</action>
</actions>
</action>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<javascript/>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Photo of Glenn Daly

Glenn Daly

  • 1,270 Points 1k badge 2x thumb
Ah so you've created another model, thanks very much for your help with this, it's now resolved!
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
yw ;)