SOQL Join Opportunity, OpportunityLineItem, and Custom ObjectConverting SQL to SOQLappend '__r' after the...
Can a broken/split chain be reassembled?
When is it acceptable to write a bad letter of recommendation?
Is "ln" (natural log) and "log" the same thing if used in this answer?
A high quality contribution but an annoying error is present in my published article
Does Sitecore have support for Sitecore products in containers?
Guitar tuning (EADGBE), "perfect" fourths?
Can Northern Ireland's border issue be solved by repartition?
How to manage expenditure when billing cycles and paycheck cycles are not aligned?
Would Taiwan and China's dispute be solved if Taiwan gave up being the Republic of China?
What is the meaning of word 'crack' in chapter 33 of A Game of Thrones?
What can a pilot do if an air traffic controller is incapacitated?
Is it true that, "just ten trading days represent 63 per cent of the returns of the past 50 years"?
What is the difference between an astronaut in the ISS and a freediver in perfect neutral buoyancy?
If an object moving in a circle experiences centripetal force, then doesn't it also experience centrifugal force, because of Newton's third law?
Is this Portent-like spell balanced?
Why does this image of Jupiter look so strange?
Safely hang a mirror that does not have hooks
Hiking with a mule or two?
Can I take NEW (still in their boxes) PC PARTS in my checked in luggage?
Why did UK NHS pay for homeopathic treatments?
I reverse the source code, you negate the input!
My manager quit. Should I agree to defer wage increase to accommodate budget concerns?
Why weren't the Death Star plans transmitted electronically?
What's the story to "WotC gave up on fixing Polymorph"?
SOQL Join Opportunity, OpportunityLineItem, and Custom Object
Converting SQL to SOQLappend '__r' after the custom relationship nameWhat is wrong with my relationship?Didn't understand relationship 'opportunity__c' in field pathSOQL Query Opportunity Custom filed lookup on user tableRelationship problems in DML/SOQLHow do I find the child relationship name?How to do a SOQL left joinNested SOQL query giving errorHow do you pull data from two objects using a soql query?Didn't understand relationship 'Opportunities' in FROM part of query call
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm trying to join two standard objects, and a custom object. I need to join OpportunityLineItem, Opportunity, and MyObject. All tables have references to each other.
MyObject has OpportunityLineItemID__c which points back to OpportunityLineItem's Id. The OpportunityLineItem has OpportunityId which maps back to Opportunity's Id.
In standard SQL I'd write this as:
SELECT *
FROM OpportunityLineItem as oli
join Opportunity as o
on oli.OpportunityId = o.id
join myobject as m
on m.id = oli.id
where ...
I tried with the __r notation but I get an error about the relations:
Didn't understand relationship 'myobject__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
My SQOL attempt:
SELECT myobject__r.fieldIwantInThisTable
FROM OpportunityLineItem where ....
I'm leaving out the Opportunity for MVCE.
soql relationships object-relational-mapping
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment
|
I'm trying to join two standard objects, and a custom object. I need to join OpportunityLineItem, Opportunity, and MyObject. All tables have references to each other.
MyObject has OpportunityLineItemID__c which points back to OpportunityLineItem's Id. The OpportunityLineItem has OpportunityId which maps back to Opportunity's Id.
In standard SQL I'd write this as:
SELECT *
FROM OpportunityLineItem as oli
join Opportunity as o
on oli.OpportunityId = o.id
join myobject as m
on m.id = oli.id
where ...
I tried with the __r notation but I get an error about the relations:
Didn't understand relationship 'myobject__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
My SQOL attempt:
SELECT myobject__r.fieldIwantInThisTable
FROM OpportunityLineItem where ....
I'm leaving out the Opportunity for MVCE.
soql relationships object-relational-mapping
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
DoesOpportunityLineItemhave a relationship field that points to yourMyObject__cobject? I answered a similar question here about 2.5 years ago that you might find helpful.
– Derek F
10 hours ago
OpportunityLineItemdoes not have a custom field that maps toMyObject__c. Theidfield in that table maps toOpportunityLineItemID__cinmyobject__cthough. Perhaps I need to run thefrom myobject__crather thanOpportunityLineItemand then useOpportunityLineItem__r...for the fields I want?
– user3783243
10 hours ago
add a comment
|
I'm trying to join two standard objects, and a custom object. I need to join OpportunityLineItem, Opportunity, and MyObject. All tables have references to each other.
MyObject has OpportunityLineItemID__c which points back to OpportunityLineItem's Id. The OpportunityLineItem has OpportunityId which maps back to Opportunity's Id.
In standard SQL I'd write this as:
SELECT *
FROM OpportunityLineItem as oli
join Opportunity as o
on oli.OpportunityId = o.id
join myobject as m
on m.id = oli.id
where ...
I tried with the __r notation but I get an error about the relations:
Didn't understand relationship 'myobject__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
My SQOL attempt:
SELECT myobject__r.fieldIwantInThisTable
FROM OpportunityLineItem where ....
I'm leaving out the Opportunity for MVCE.
soql relationships object-relational-mapping
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm trying to join two standard objects, and a custom object. I need to join OpportunityLineItem, Opportunity, and MyObject. All tables have references to each other.
MyObject has OpportunityLineItemID__c which points back to OpportunityLineItem's Id. The OpportunityLineItem has OpportunityId which maps back to Opportunity's Id.
In standard SQL I'd write this as:
SELECT *
FROM OpportunityLineItem as oli
join Opportunity as o
on oli.OpportunityId = o.id
join myobject as m
on m.id = oli.id
where ...
I tried with the __r notation but I get an error about the relations:
Didn't understand relationship 'myobject__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
My SQOL attempt:
SELECT myobject__r.fieldIwantInThisTable
FROM OpportunityLineItem where ....
I'm leaving out the Opportunity for MVCE.
soql relationships object-relational-mapping
soql relationships object-relational-mapping
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 10 hours ago
user3783243user3783243
1133 bronze badges
1133 bronze badges
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user3783243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
DoesOpportunityLineItemhave a relationship field that points to yourMyObject__cobject? I answered a similar question here about 2.5 years ago that you might find helpful.
– Derek F
10 hours ago
OpportunityLineItemdoes not have a custom field that maps toMyObject__c. Theidfield in that table maps toOpportunityLineItemID__cinmyobject__cthough. Perhaps I need to run thefrom myobject__crather thanOpportunityLineItemand then useOpportunityLineItem__r...for the fields I want?
– user3783243
10 hours ago
add a comment
|
1
DoesOpportunityLineItemhave a relationship field that points to yourMyObject__cobject? I answered a similar question here about 2.5 years ago that you might find helpful.
– Derek F
10 hours ago
OpportunityLineItemdoes not have a custom field that maps toMyObject__c. Theidfield in that table maps toOpportunityLineItemID__cinmyobject__cthough. Perhaps I need to run thefrom myobject__crather thanOpportunityLineItemand then useOpportunityLineItem__r...for the fields I want?
– user3783243
10 hours ago
1
1
Does
OpportunityLineItem have a relationship field that points to your MyObject__c object? I answered a similar question here about 2.5 years ago that you might find helpful.– Derek F
10 hours ago
Does
OpportunityLineItem have a relationship field that points to your MyObject__c object? I answered a similar question here about 2.5 years ago that you might find helpful.– Derek F
10 hours ago
OpportunityLineItem does not have a custom field that maps to MyObject__c. The id field in that table maps to OpportunityLineItemID__c in myobject__c though. Perhaps I need to run the from myobject__c rather than OpportunityLineItem and then use OpportunityLineItem__r... for the fields I want?– user3783243
10 hours ago
OpportunityLineItem does not have a custom field that maps to MyObject__c. The id field in that table maps to OpportunityLineItemID__c in myobject__c though. Perhaps I need to run the from myobject__c rather than OpportunityLineItem and then use OpportunityLineItem__r... for the fields I want?– user3783243
10 hours ago
add a comment
|
2 Answers
2
active
oldest
votes
Salesforce, for one reason or another, doesn't allow us to make relationship fields that target OLI (OpportunityLineItem).
We can hold an OLI Id in a text field, but that won't allow you to traverse the relationship in SOQL.
Your options here are to break this into two queries (one to pull your Custom_Object__c records based on the Ids of the OLIs you are working with, one to pull the OLIs and related data from their Opportunities), or maintain a relationship field on MyObject__c to Opportunity so you can use two parent-child subqueries (left outer joins).
The two queries method might look like this:
// You'll want this to be a map so that you can easily grab the appropriate OLI when you're
// working with MyObject__c records.
// To get Opportunity data in a query on OLI, you use Opportunity.<field api name> for each field
// The relationship between OLI and Opportunity is a standard field, OpportunityId.
// The child relationship name for standard relationship fields is usually just <object name>, e.g. Opportunity
// (we drop the "Id" bit from the field name)
Map<Id, OpportunityLineItem> olisMap = new Map<Id, OpportunityLineItem>([SELECT Id, UnitPrice, Opportunity.Amount, Opportunity.AccountId FROM OpportunityLineItem WHERE Id IN :oliIds]);
List<MyObject__c> myObjs = [SELECT Id, OtherField__c FROM MyObject__c WHERE OpportunityLineItem_Id__c IN :olisMap.keySet()];
The one query approach might look like this:
// This approach also uses what Salesforce calls a semi-join
// Basically, a subquery in the WHERE clause that tells us what to query in the main query)
// I assume MyObjects__r is the child relationship name between MyObject__c and Opportunity,
// you'll likely need to change this.
// Newlines here are just for readability
List<Opportunity> oppsList = [
SELECT
Id, Amount,
(SELECT Id, UnitPrice FROM OpportunityLineItems__c),
(SELECT Id FROM MyObjects__r)
FROM Opportunity
WHERE Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Id IN :oliIds)];
Thanks, this makes sense.
– user3783243
9 hours ago
add a comment
|
Perhaps something like this would work:
SELECT Id, OpportunityId, <Other fields> FROM OpportunityLineItem WHERE OpportunityId IN: (SELECT <Opportunity Id Lookup Field> FROM myobject__c)
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment
|
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
user3783243 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f278882%2fsoql-join-opportunity-opportunitylineitem-and-custom-object%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Salesforce, for one reason or another, doesn't allow us to make relationship fields that target OLI (OpportunityLineItem).
We can hold an OLI Id in a text field, but that won't allow you to traverse the relationship in SOQL.
Your options here are to break this into two queries (one to pull your Custom_Object__c records based on the Ids of the OLIs you are working with, one to pull the OLIs and related data from their Opportunities), or maintain a relationship field on MyObject__c to Opportunity so you can use two parent-child subqueries (left outer joins).
The two queries method might look like this:
// You'll want this to be a map so that you can easily grab the appropriate OLI when you're
// working with MyObject__c records.
// To get Opportunity data in a query on OLI, you use Opportunity.<field api name> for each field
// The relationship between OLI and Opportunity is a standard field, OpportunityId.
// The child relationship name for standard relationship fields is usually just <object name>, e.g. Opportunity
// (we drop the "Id" bit from the field name)
Map<Id, OpportunityLineItem> olisMap = new Map<Id, OpportunityLineItem>([SELECT Id, UnitPrice, Opportunity.Amount, Opportunity.AccountId FROM OpportunityLineItem WHERE Id IN :oliIds]);
List<MyObject__c> myObjs = [SELECT Id, OtherField__c FROM MyObject__c WHERE OpportunityLineItem_Id__c IN :olisMap.keySet()];
The one query approach might look like this:
// This approach also uses what Salesforce calls a semi-join
// Basically, a subquery in the WHERE clause that tells us what to query in the main query)
// I assume MyObjects__r is the child relationship name between MyObject__c and Opportunity,
// you'll likely need to change this.
// Newlines here are just for readability
List<Opportunity> oppsList = [
SELECT
Id, Amount,
(SELECT Id, UnitPrice FROM OpportunityLineItems__c),
(SELECT Id FROM MyObjects__r)
FROM Opportunity
WHERE Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Id IN :oliIds)];
Thanks, this makes sense.
– user3783243
9 hours ago
add a comment
|
Salesforce, for one reason or another, doesn't allow us to make relationship fields that target OLI (OpportunityLineItem).
We can hold an OLI Id in a text field, but that won't allow you to traverse the relationship in SOQL.
Your options here are to break this into two queries (one to pull your Custom_Object__c records based on the Ids of the OLIs you are working with, one to pull the OLIs and related data from their Opportunities), or maintain a relationship field on MyObject__c to Opportunity so you can use two parent-child subqueries (left outer joins).
The two queries method might look like this:
// You'll want this to be a map so that you can easily grab the appropriate OLI when you're
// working with MyObject__c records.
// To get Opportunity data in a query on OLI, you use Opportunity.<field api name> for each field
// The relationship between OLI and Opportunity is a standard field, OpportunityId.
// The child relationship name for standard relationship fields is usually just <object name>, e.g. Opportunity
// (we drop the "Id" bit from the field name)
Map<Id, OpportunityLineItem> olisMap = new Map<Id, OpportunityLineItem>([SELECT Id, UnitPrice, Opportunity.Amount, Opportunity.AccountId FROM OpportunityLineItem WHERE Id IN :oliIds]);
List<MyObject__c> myObjs = [SELECT Id, OtherField__c FROM MyObject__c WHERE OpportunityLineItem_Id__c IN :olisMap.keySet()];
The one query approach might look like this:
// This approach also uses what Salesforce calls a semi-join
// Basically, a subquery in the WHERE clause that tells us what to query in the main query)
// I assume MyObjects__r is the child relationship name between MyObject__c and Opportunity,
// you'll likely need to change this.
// Newlines here are just for readability
List<Opportunity> oppsList = [
SELECT
Id, Amount,
(SELECT Id, UnitPrice FROM OpportunityLineItems__c),
(SELECT Id FROM MyObjects__r)
FROM Opportunity
WHERE Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Id IN :oliIds)];
Thanks, this makes sense.
– user3783243
9 hours ago
add a comment
|
Salesforce, for one reason or another, doesn't allow us to make relationship fields that target OLI (OpportunityLineItem).
We can hold an OLI Id in a text field, but that won't allow you to traverse the relationship in SOQL.
Your options here are to break this into two queries (one to pull your Custom_Object__c records based on the Ids of the OLIs you are working with, one to pull the OLIs and related data from their Opportunities), or maintain a relationship field on MyObject__c to Opportunity so you can use two parent-child subqueries (left outer joins).
The two queries method might look like this:
// You'll want this to be a map so that you can easily grab the appropriate OLI when you're
// working with MyObject__c records.
// To get Opportunity data in a query on OLI, you use Opportunity.<field api name> for each field
// The relationship between OLI and Opportunity is a standard field, OpportunityId.
// The child relationship name for standard relationship fields is usually just <object name>, e.g. Opportunity
// (we drop the "Id" bit from the field name)
Map<Id, OpportunityLineItem> olisMap = new Map<Id, OpportunityLineItem>([SELECT Id, UnitPrice, Opportunity.Amount, Opportunity.AccountId FROM OpportunityLineItem WHERE Id IN :oliIds]);
List<MyObject__c> myObjs = [SELECT Id, OtherField__c FROM MyObject__c WHERE OpportunityLineItem_Id__c IN :olisMap.keySet()];
The one query approach might look like this:
// This approach also uses what Salesforce calls a semi-join
// Basically, a subquery in the WHERE clause that tells us what to query in the main query)
// I assume MyObjects__r is the child relationship name between MyObject__c and Opportunity,
// you'll likely need to change this.
// Newlines here are just for readability
List<Opportunity> oppsList = [
SELECT
Id, Amount,
(SELECT Id, UnitPrice FROM OpportunityLineItems__c),
(SELECT Id FROM MyObjects__r)
FROM Opportunity
WHERE Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Id IN :oliIds)];
Salesforce, for one reason or another, doesn't allow us to make relationship fields that target OLI (OpportunityLineItem).
We can hold an OLI Id in a text field, but that won't allow you to traverse the relationship in SOQL.
Your options here are to break this into two queries (one to pull your Custom_Object__c records based on the Ids of the OLIs you are working with, one to pull the OLIs and related data from their Opportunities), or maintain a relationship field on MyObject__c to Opportunity so you can use two parent-child subqueries (left outer joins).
The two queries method might look like this:
// You'll want this to be a map so that you can easily grab the appropriate OLI when you're
// working with MyObject__c records.
// To get Opportunity data in a query on OLI, you use Opportunity.<field api name> for each field
// The relationship between OLI and Opportunity is a standard field, OpportunityId.
// The child relationship name for standard relationship fields is usually just <object name>, e.g. Opportunity
// (we drop the "Id" bit from the field name)
Map<Id, OpportunityLineItem> olisMap = new Map<Id, OpportunityLineItem>([SELECT Id, UnitPrice, Opportunity.Amount, Opportunity.AccountId FROM OpportunityLineItem WHERE Id IN :oliIds]);
List<MyObject__c> myObjs = [SELECT Id, OtherField__c FROM MyObject__c WHERE OpportunityLineItem_Id__c IN :olisMap.keySet()];
The one query approach might look like this:
// This approach also uses what Salesforce calls a semi-join
// Basically, a subquery in the WHERE clause that tells us what to query in the main query)
// I assume MyObjects__r is the child relationship name between MyObject__c and Opportunity,
// you'll likely need to change this.
// Newlines here are just for readability
List<Opportunity> oppsList = [
SELECT
Id, Amount,
(SELECT Id, UnitPrice FROM OpportunityLineItems__c),
(SELECT Id FROM MyObjects__r)
FROM Opportunity
WHERE Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Id IN :oliIds)];
answered 10 hours ago
Derek FDerek F
23.4k6 gold badges26 silver badges55 bronze badges
23.4k6 gold badges26 silver badges55 bronze badges
Thanks, this makes sense.
– user3783243
9 hours ago
add a comment
|
Thanks, this makes sense.
– user3783243
9 hours ago
Thanks, this makes sense.
– user3783243
9 hours ago
Thanks, this makes sense.
– user3783243
9 hours ago
add a comment
|
Perhaps something like this would work:
SELECT Id, OpportunityId, <Other fields> FROM OpportunityLineItem WHERE OpportunityId IN: (SELECT <Opportunity Id Lookup Field> FROM myobject__c)
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment
|
Perhaps something like this would work:
SELECT Id, OpportunityId, <Other fields> FROM OpportunityLineItem WHERE OpportunityId IN: (SELECT <Opportunity Id Lookup Field> FROM myobject__c)
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment
|
Perhaps something like this would work:
SELECT Id, OpportunityId, <Other fields> FROM OpportunityLineItem WHERE OpportunityId IN: (SELECT <Opportunity Id Lookup Field> FROM myobject__c)
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Perhaps something like this would work:
SELECT Id, OpportunityId, <Other fields> FROM OpportunityLineItem WHERE OpportunityId IN: (SELECT <Opportunity Id Lookup Field> FROM myobject__c)
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 10 hours ago
ZachZach
517 bronze badges
517 bronze badges
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment
|
add a comment
|
user3783243 is a new contributor. Be nice, and check out our Code of Conduct.
user3783243 is a new contributor. Be nice, and check out our Code of Conduct.
user3783243 is a new contributor. Be nice, and check out our Code of Conduct.
user3783243 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f278882%2fsoql-join-opportunity-opportunitylineitem-and-custom-object%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Does
OpportunityLineItemhave a relationship field that points to yourMyObject__cobject? I answered a similar question here about 2.5 years ago that you might find helpful.– Derek F
10 hours ago
OpportunityLineItemdoes not have a custom field that maps toMyObject__c. Theidfield in that table maps toOpportunityLineItemID__cinmyobject__cthough. Perhaps I need to run thefrom myobject__crather thanOpportunityLineItemand then useOpportunityLineItem__r...for the fields I want?– user3783243
10 hours ago