You need to sign in to do that
Don't have an account?
Najoop
Semi Join Query isong SOQL
Hi,
I am trying to write a S-control which returns the number of SelfService Contacts for the Account.
I am not able to get this query worked.
SELECT Id from selfserviceuser where ContactID IN (Select ContactID from Contact where AccountID={!Account.Id}";
I am learning writing Apex and triggers to any help is appreciated. I tried searching the APex guide and cookbook but did not exactly understood how to get this working. it may be incorrect syntax for child to parent relationship query.
any help is appreciated.
Najoop Poojan.
Hey
Considering that salesforce is deprecating S-Controls perhaps you should instead use a Visualforce page for your results.
First you would need a list to hold the data, and a method to return that list to your VisualForce page.
The variable and SOQL query:
List<SelfServiceuser> ssuList = new List<SelfServiceUser>();
List<Contact> contacts = [SELECT id FROM Contact WHERE accountId=:AcctId];
for(Contact c: contacts){
try{
SelfServiceUser ssu = [SELECT id FROM SelfServiceUser WHERE contactId=:c.id];
ssuList.add(ssu);
catch (System.QueryException e){}}
Please note that you should never put queries in loops like I did above. But that should be enough to get you started.
Cheers,
Wes
there is no contactId field on contact, try this query instead
select id from selfserviceuser where contactId in ( select id from contact where accountId='someAcctId')
Thanks all,
The query didnt worked, I am trying to get the number of contacts for specific account and here is the function I wrote. I migh tbe totally off, but these are my first steps on learning apex.
This function is written inside a HTML link control
function Init() {
try
{
var SearchString="SELECT ID from SelfServiceUser where ContactID IN (Select ID from Contacts where AccountID={!Account.Id}";
var queryResults = sforce.connection.query(SearchString);
var queryRecords = queryResults.getArray('records');
var txtOutput = "";
document.getElementById("mainBody").innerHTML = queryRecords.length;
}
catch(error)
{
alert(error.faultline);
}
}
thanks,
Najoop Poojan.