global class Jive_CTI_Salesforce_RelatedInfoApex {
webService static String getOpportunities(String accountId){
List<Object> opportunities = new List<Object>();
List<Object> dataSet = Database.query(‘SELECT Id, Name, AccountId, Description FROM Opportunity WHERE AccountId = :accountId’);
for(Object item : dataSet){
opportunities.add(item);
}
try{
String JSONString = JSON.serialize(opportunities);
return JSONString;
}catch(DMLException e){
system.debug(‘DML Exception: ‘ + e);
return null;
}
}
webService static String getCases(String entityId){
List<Object> cases = new List<Object>();
List<Object> dataSet = Database.query(‘SELECT Id, AccountId, ContactId, CaseNumber, Subject, Description FROM Case WHERE AccountId = :entityId OR ContactId = :entityId’);
for(Object item : dataSet){
cases.add(item);
}
try{
String JSONString = JSON.serialize(cases);
return JSONString;
}catch(DMLException e){
system.debug(‘DML Exception: ‘ + e);
return null;
}
}
webService static String getLastNotes(String entityId, Integer itemsNo){
List<Object> notes = new List<Object>();
List<Object> dataSet = Database.query(‘SELECT Id, Subject, Description, WhatId, CreatedById, ActivityDate, CreatedDate FROM Task WHERE WhatId = :entityId ORDER BY CreatedDate DESC LIMIT ‘ + itemsNo);
for(Object item : dataSet){
notes.add(item);
}
try{
String JSONString = JSON.serialize(notes);
return JSONString;
}catch(DMLException e){
system.debug(‘DML Exception: ‘ + e);
return null;
}
}
}

Was this help page useful? Send feedback.

Was this help page useful?


This form is to provide feedback on our help pages. if you need assistance, let's talk—we'd love to hear from you.