Query opportunity partner to get the fields from account - salesforce

How can I get the name of the partner from a opportunity partner?
I want to get the name of the account which is partner of that opportunity account

If you want to get Name of account which is related to the opportunity record, you can just refer to account fields using dot-syntax, something like that:
SELECT Id, Name, Account.Name FROM Opportunity

Related

SOQL Profile Names, Permission Set, User Name

I am accustomed to using SQL, and have been thrown into the SOQL Salesforce realm quickly without much idea on how to use SOQL.
I have been trying to create a simple query to get the above fields all in one table so that I can see for each user their profile name, user name and the permission set that they have. This is a simple query but using workbench I have not been able to get it. Thanks!
SELECT FirstName,LastName,PortalRole, ProfileId, Profile.Name, Profile.userType, Username, UserRoleId,UserType, Profile.PermissionsAccessCMC, Profile.PermissionsActivateContract,Profile.PermissionsActivitiesAccess FROM User
That is you can get all the permission from profile table. In the above SOQL, I have added some of the permission fields from profile.

Is it possible to get all member details of group in Active Directory?

I am querying AD with cn='group_name' and I am getting all the members of group
which contains only CN='Employeeid'. But is it possible to get all members
details which includes firstname, email, lastname of members of group in one query?
Usually works on most installations of Microsoft Active Directory the query:
(&(objectClass=user)(memberof:1.2.840.113556.1.4.1941:=CN=GroupOne,OU=Security Groups,OU=Groups,DC=YOURDOMAIN,DC=NET)
Returning the list attribute you want to see:
givenname sn mail etc.

SOQL query doesn't retrieve all contacts

I am working on a code snippet that is supposed to import all my contacts from Salesforce via SOQL.
Here is what I do when I want to import all Salesforce contacts for my user 00520000001IbXZAA0
First SOQL:
SELECT Id FROM account WHERE ownerid = ‘00520000001IbXZAA0’
Then I get all the account id where I am a team member:
SELECT AccountId FROM accountteammember WHERE UserId = ‘00520000001IbXZAA0’
Then I build an array with my ids and from my 2 previous requests and get all contacts this way:
SELECT FirstName, LastName, Account.Name FROM Contact WHERE AccountId IN myarrayofids ORDER BY CreatedDate ASC
This approach seems to get most of my contacts but I can still see some contacts appear in Salesforce but that are not retrieved with these 3 queries. Am I missing something here?
I have only very few knowledge of how Salesforce work but I suppose that if I retrieve all contacts where I am a team member or owner, I should retrieve all contacts I am able to see on Salesforce or am I missing something here?
Many thanks
The reason you are not able to see all records otherwise is as some might be shared with you via OWD or using role based sharing, manual sharing or apex sharing. If you are just looking for a list in csv or anything, the easiest thing you can do here is create a report to display all contacts and share it with this user. Login into Salesforce as this "00520000001IbXZAA0" user. Run the report and export into csv/excel.
If you wish to do this in code, write a class using "with sharing" keyword and run the following query "Select Id, FirstName, LastName .... From Contact". This will return this user all the records she/he has access to.
Try these above solutions and let me know if they work for you. Happy to help..!!

Returning all Salesforce contacts associated with an account via query from third-party site

I'm using Survey Gizmo and I want to pull in all contact emails associated with an account.
This query works, but it only pulls in the first contact and I need them all:
SELECT Id,Contact.Email FROM Contact WHERE AccountId = 'Insert_Account_Id_Here'
How can I pull in more than one contact?
If that's not possible, is it possible to specifically pull in contact "N"? Then, question 1 could pull in contact 1, question 2 could pull in contact 2 and so forth.
Thanks... I'm new to this so let me know if that was unclear.
Select id,(select Email from contacts) from Acount where id =:'acountLd
for (contact con:acc.Contacts){ con.Email....}

How to limit SOQL results to those accessible to a user

I have admin API access for my organization. I'd like to run the same SOQL query, but get back results as visible to various users in my org: running "SELECT Name FROM Account" for user A, should only return account names accessible to user A.
I know this is easy if each user provides my application with their password and security token, so I can log in as them and run the query, but I want to do this only using my admin account.
this is very similar to:
Salesforce: impersonation using the API
but in this case I do have access to the data, I just want to filter it as though the request came from a specific user. It looks like there's an Apex "unit testing" method called System.RunAs() which looks close, but I want to run this via REST.
I think that you can filter the first SOQL query using HasReadAccess from UserRecordAccess table.
You could try building a set of RecordIDs first and then using this to filter the Account query.
Set<ID> sRecordIDs = [SELECT RecordID FROM UserRecordAccess WHERE UserId = :u AND HasReadAccess = True];
Account[] accs =[SELECT ID,Name FROM Account WHERE Id in :sRecordIDs];
More details on the official documentation

Resources