+ Start a Discussion
viswanadham Aviswanadham A 

how to write a query on below condtion?

HI ,

Find accounts which are enabled as partner user  and doesn't have partner user ?
 
Narveer SinghNarveer Singh
Hi Viswa,

You can use below query to get Account enabled as partner User :

Select Name, Site, Status__c FROM Account where ID IN (Select AccountToId from Partner);

you can use  where AccountFromId = 'ID' for a specific ID as well.

Hope this helps you!

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution.

Best Regards
Narveer



 
AdrianCCAdrianCC
Hello,

Question: are you asking about AccountPartners (the partner relationship between two Account objects) or the Account records that have been enabled for the partner portal?
If it is about AccounPartners the soql would look like this: SELECT Id FROM Account WHERE Id NOT IN (SELECT AccountFromId FROM AccountPartner)
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_partner.htm
I'm not sure the NOT IN works out of the box for soql like this, but you can use a set for the AccountFromIds extracted with a separate soql

Thanks,
Adrian