Afternoon,
I am gathering data from the LiveChatTranscript and there are multiple references to user as lookup fields. How do I pick which property I want to use as my reference to user?
LiveChatTranscript properties
LastModifiedById Lookup(User)
CreatedById Lookup(User)
OwnerId Lookup(User,Group)
query
-webroot-/query/?q=select chatkey, caseid, status,requesttime, starttime, endtime,endedby,name,ReferrerUri,platform,location, waittime,body,supervisortranscriptbody, case.description, ownerid,ownerid.user.alias?? from livechattranscript where chatkey = '12345'
In this case, owner is the field name. It looks up to the user object. No need to include the object name there. Just drop the id potion for ownerid.
Use owner.alias.
Related
I am trying to get just get the permissionSetGroupComponents for test users in Salesforce with this query.
SELECT AssigneeId, IsActive, ExpirationDate, PermissionSetGroupId, PermissionSetId FROM PermissionSetAssignment WHERE User.FirstName = 'Test'
But when I run that I get this error.
PermissionSetAssignment WHERE User.FirstName = 'Test'
^
ERROR at Row:1:Column:119
Didn't understand relationship 'User' 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.
According to the API documentation there is a relationship between the two objects so I don't understand why it cannot find the relationship.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_permissionsetassignment.htm
User is not the name of the relationship. The relationship field is AssigneeId, so the relationship field is Assignee:
SELECT AssigneeId, IsActive, ExpirationDate, PermissionSetGroupId, PermissionSetId
FROM PermissionSetAssignment
WHERE Assignee.FirstName = 'Test'
I have a junction object called "JIRA_Data" and its linked/ related to Accounts. How do I query to fetch data from this relationship. I am trying to extract id,type from Account object and Name from JIRA_Data junction object.
Could anyone assist. Thanks
You could do it multiple ways depending on how you want the data. If you query it from the parent account it would be something to the effect:
SELECT Id, Name, (Select ID, Name, Other_Parent__r.Name FROM Jira_Datas__r) FROM Account
or from the junction
SELECT Id, Name, Account.Name, Other_Parent__r.Name FROM Jira_Data__c
I have a custom object called 'Billings'. On that object there is a custom lookup field to the Opportunity. I'm trying to query all the 'Billings' records associated with a particular Opportunity. I get "Unknown error parsing query".
SELECT Id, StageName,
( SELECT Name, Email FROM Billings__C )
FROM Opportunity WHERE Opportunity ID = '0011000002mfTil'
For Nested Queries in SOQL, you need to use the '__r' suffix on the Child Relationship Name for the field that provides the look-up from the Child Record to the Parent.
In your case, this is most likely 'Billings__r'. However, to confirm, go to the Billings object and click on the custom field that provides the lookup to the Opportunity object. In the "Lookup Options" section on the Custom Field details screen you will see the official Child Relationship Name without the '__r' suffix. This is the correct name for this relationship for a Nested Query.
The other error in your query is that you have "WHERE Opportunity Id =". It should just be "WHERE Id ="
Based on the information you provided, your query should be:
SELECT Id, StageName, ( SELECT Name, Email FROM Billings__r ) FROM Opportunity WHERE ID = '0011000002mfTil'
I am trying to fetch picklist records from sales force using soql. My Table name is Industry__c its having a field called Industry_Group__c whose data type is picklist. How can I fetch the records of the Industry_group__c picklist.
I have tried the below queries but it did not work.
select Industry_Group__c from Industry__c
First get the DurableId from the FieldDefinition:
Select DurableId
From FieldDefinition
where EntityDefinition.DeveloperName='Industry__c'
and DataType = 'Picklist'
and DeveloperName = 'Industry_Group__c'
Then you can run the following query to get out the picklist values, replacing the EntityParticleId with the DurableId from the last query:
SELECT DurableId, EntityParticleId, IsActive, IsDefaultValue, Label, ValidFor, Value
FROM PicklistValueInfo
WHERE EntityParticleId = 'Account.00N1a00000ZZSAS'
Actually the field is not accessible to user .. Please check the field level security whether it has a read/Write access to system Administrator and then try to access it..
Hey Salesforce experts,
I have a question on query account information efficiently. I would like to query accounts based on the updates in an activityHistory object. The problem I'm getting is that all the accounts are being retrieved no matter if there's "complete" activeHistory or not. So, Is there a way I can write this query to retrieve only accounts with activeHistory that has status="complete" and Type_for_reporting='QRC'?
List<Account> AccountsWithActivityHistories = [
SELECT
Id
,Name
,( SELECT
ActivityDate
,ActivityType
,Type_for_Reporting__c
,Description
,CreatedBy.Name
,Status
,WhatId
FROM ActivityHistories
WHERE Status ='complete' and Type_for_Reporting__c = 'QRC'
)
FROM Account
];
You have a WHERE clause on the histories but you still miss one on the Account level.
For example this would return only Accounts that have Contacts:
SELECT Id, Name
FROM Account
WHERE Id IN (SELECT AccountId FROM Contact) // try with NOT IN too
With Activities it's trickier because they don't like to be used in WHERE in that way.
http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_select.htm
The following objects are not currently supported in subqueries:
ActivityHistory
Attachments
Event
EventAttendee
Note
OpenActivity
Tags (AccountTag, ContactTag, and all other tag objects)
Task
Additionally the fine print at the bottom of ActivityHistory definition is also a bit discouraging.
The following restrictions on users who don’t have “View All Data” permission help prevent performance issues:
In the main clause of the relationship query, you can reference only
one record. For example, you can’t filter on all records where the
account name starts with ‘A’; instead, you must reference a single
account record.
You can’t use WHERE clauses.
You must specify a limit of 499 or fewer on the number of rows returned in the list.
You must sort on ActivityDate in ascending order and LastModifiedDate in descending order; you can display nulls last. For
example: ORDER BY ActivityDate ASC NULLS LAST, LastModifiedDate DESC.
Looks like you will need multiple queries. Go for Task (or Event, depending for which the custom field is visible), compose a set of AccountIds and then query the Accounts?
Or you can manually filter through list from your original query, copying accounts to helper list:
List<Account> finalResults = new List<Account>();
for(Account a : [SELECT...]){
if(!a.ActivityHistories.isEmpty()){
finalResults.add(a);
}
}