• murali krishna.ax1501
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies

I have one custom object the chatter user as to change the value of one filed is it possible to change.

How can I give  custom object access to chatter user.

I am getting this error for below StandardSetController code

 

14:28:20.105 (105857000)|EXCEPTION_THROWN|[13]|System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.

Even if a field is indexed a filter might still not be selective when:

1. The filter value includes null (for instance binding with a list that contains null)

 

 

//////-----------------------------------------------------------------------------------------

public class duplicateSMSFinder{

 public static string processNo;

 public ApexPages.StandardSetController setCon {
 
        get {
                  
              if(setCon == null && processNo !=null)
                {
                try{
                      system.debug(processNo+'ddddddddd');
                      setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id,
                                                    Email,
                                                    Customer_Mobile__c,
                                                    Mobile_Number__c from
                                                    lead where
                                                       Customer_Mobile__c=:processNo limit 1]));
                      
                   }catch(exception e){}  
                      
                }//if
               
            return setCon;
        }     
        set;
    }//construcor

    // Initialize setCon and return a list of records
    
    public List<lead> getleadLists(string pSMSNO) {
    processNo=pSMSNO;
     if(setCon != null){
     return (List<lead>)setCon.getRecords();    
     }
     else{return null;}
    
    }
                
} //end of class

 

//////-----------------------------------------------------------------------------------------

I have one custom object the chatter user as to change the value of one filed is it possible to change.

How can I give  custom object access to chatter user.

I am getting this error for below StandardSetController code

 

14:28:20.105 (105857000)|EXCEPTION_THROWN|[13]|System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.

Even if a field is indexed a filter might still not be selective when:

1. The filter value includes null (for instance binding with a list that contains null)

 

 

//////-----------------------------------------------------------------------------------------

public class duplicateSMSFinder{

 public static string processNo;

 public ApexPages.StandardSetController setCon {
 
        get {
                  
              if(setCon == null && processNo !=null)
                {
                try{
                      system.debug(processNo+'ddddddddd');
                      setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id,
                                                    Email,
                                                    Customer_Mobile__c,
                                                    Mobile_Number__c from
                                                    lead where
                                                       Customer_Mobile__c=:processNo limit 1]));
                      
                   }catch(exception e){}  
                      
                }//if
               
            return setCon;
        }     
        set;
    }//construcor

    // Initialize setCon and return a list of records
    
    public List<lead> getleadLists(string pSMSNO) {
    processNo=pSMSNO;
     if(setCon != null){
     return (List<lead>)setCon.getRecords();    
     }
     else{return null;}
    
    }
                
} //end of class

 

//////-----------------------------------------------------------------------------------------

 

 

Hi All,

 

I am trying to develop an application through which I can send/receive message from  any Object (like Contact).
 I am able to send message from salesforce through "SMS Gateway" but I am not able to send a message to contact Object.

How can we receive messages in Salesforce?

 

 

 

Thanks,

Varun

 

Hi 

 

   I developed Force.com sites pages and gave login access to my customer portal users.I made a callout in one of the Vf page in my site. whenever the callout failed, salesforce sites throw me to the Site Exception page. 

 

   My doubt is can we show a custom message in the exception page according to the callout error?  or else Is it possible to  catch the exception of that callout and show it in the exception page.

 

  Need help on the above query?

 

 

Thanks

Marris

  • October 05, 2012
  • Like
  • 0

Hi 

 

I am getting error  : Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 137.203KB 

 

we have button on case, to create Csae Time report, We have Comments, Child cases, emails and attachments. I think, I am getting error  because of  attachment method @ public void setupAttachments(Case c, list<caseHistoryItem>tList),  Please find controller  and Visualforce Page below.

 

Anybody have any idea let me know.

Thanks in advance.

 

Controller:

 

public with sharing class CaseHistoryController {
private static String CLASSNAME = '\n\n**** CaseHistoryController.@@METHODNAME()';
public list<CaseHistoryItem> CHIlist {get; set;}
public Case aCase {get; set;}
public String caseID {get; set;}
public list<Task> tasks {get; set;}
public boolean showAll {get; set;}
public Set<String> prefixSet {get; set;}
public boolean isReachout {get; set;}
public Boolean showPrivate {get; set;}
public Boolean showEmail {get; set;}
public Boolean showComment {get; set;}
public Boolean showAttach {get; set;}
public Boolean showpAttach {get; set;}
public Boolean showHist {get; set;}
public Boolean showRCase {get; set;}
public map <integer,List<caseHistoryItem>> listIndex {get; set;}
public integer listIndexInt {get; set;}

public string filterString { get; set; }

public string sortField { get; set; }
public string previousSortField { get; set; }
public string order { get; set; }
public string rCaseSortMethod { get; set; }

public string emailSubject { get; set; }
public string emailBody { get; set; }
public string additionalTo { get; set; }
public boolean bccOwner { get; set; }
public boolean sendToCaseContact { get; set; }

public CaseHistoryController()
{
caseId = Apexpages.currentPage().getParameters().get('id');

showPrivate = true;

showEmail = true;

showComment = true;

showAttach = true;

showHist = true;

showRCase = true;

showpAttach = true;

rCaseSortMethod = 'separate';

order = 'asc';

sortField = 'CreateDate';

previousSortField = 'CreateDate';

sendToCaseContact = false;
bccOwner = false;

refreshHistory();

emailSubject = 'Case ' + aCase.CaseNumber + ' Timeline Report';
emailBody = 'Your Case Timeline Report is attached.';
}

public Case queryCase(id cId)
{
String METHODNAME = CLASSNAME.replace('@@METHODNAME','queryCase');
String emailWhere = 'where Subject like \'Email%\'';
String commentWhere = 'where id != null';
String histWhere = 'where id != null';
String rCaseWhere = 'where id != null';
String attachWhere = 'where id != null';

if (showPrivate == False) {
commentWhere += ' and isPublished = True';
emailWhere += ' and isVisibleinSelfService = True';
rCaseWhere += ' and isVisibleinSelfService = True';
// phani Emmanni on 04/15/2012
//attachWhere += ' and ispublic = true';
}

//building select all for case using describe info
Schema.DescribeSObjectResult d = Schema.Sobjecttype.Case;

map<string, Schema.SobjectField> fieldMap = d.fields.getMap();

list<Schema.SObjectField> tempFields = fieldMap.values();

string caseAllFields = '';

for(Schema.Sobjectfield sof:tempFields)
{
caseAllFields += (','+sof.getDescribe().getName());
}

String caseQuery = 'select RecordType.Name, Account.Name, Contact.Name, Contact.Email, Contact.Phone, Owner.Email ,CreatedBy.Name, Owner.Name, Contact.Contact_Full_Name__c' + caseAllFields;
String emailQuery = ',(Select Id, CreatedById, CreatedBy.Name, WhatId, What.Name, Subject, ActivityDate, Status, OwnerId, Description, CreatedDate, Owner.Name, isVisibleInSelfService From Tasks '+emailWhere+')';
String commentQuery = ',(Select Id, CreatedDate, CreatedBy.Name, CreatedById, CommentBody, isPublished From CaseComments '+commentWhere+')';
String histQuery = ',(Select Id, CreatedById, CreatedBy.Name, CreatedDate, Field, OldValue, NewValue From Histories '+histWhere+')';
String rCaseQuery = ',(select Id from ReachOutCases__r '+rCaseWhere+')';
String attachQuery = ',(select Id, CreatedById, CreatedBy.Name, CreatedDate, Name, Owner.Name, isprivate from Attachments '+attachWhere+')';

if (showPrivate) {
if (showEmail) {
caseQuery += emailQuery;
}
if (showComment) {
caseQuery += commentQuery;
}
if (showRCase) {
caseQuery += rCaseQuery;
}
if (showHist) {
caseQuery += histQuery;
}
if (showAttach) {
caseQuery += attachQuery;
}

} else {
if (showEmail) {
caseQuery += emailQuery;
}
if (showComment) {
caseQuery += commentQuery;
}
if (showRCase) {
caseQuery += rCaseQuery;
}
}

caseQuery += ' from Case where ID = \''+cID+'\'';
//System.debug('------------------------->'+caseQuery);
system.debug(LoggingLevel.INFO, METHODNAME + ' :: caseQuery = ' + caseQuery +'\n\n');
case c = database.query(caseQuery);
return c;
}

public void refreshHistory() {
CHIlist= new List<CaseHistoryItem>();
listIndex = new Map<integer,List<CaseHistoryItem>>();

listIndex.put(0,CHIlist);

aCase = queryCase(caseId);

isReachout = (aCase.RecordType.Name.Contains('Reachout')||aCase.RecordType.Name.Contains('Reach Out'));

if (showPrivate)
{
if (showEmail)
{
setupEmails(aCase, CHIList);
}
if (showComment)
{
setupCaseComments(aCase, CHIList);
}
if (showRCase)
{
setupReachOutCases(aCase, CHIList);
}
if (showHist)
{
setupHistories(aCase, CHIList);
}
if (showAttach) {
setupAttachments(aCase, CHIList);
}
}
else
{
if (showEmail)
{
setupEmails(aCase, CHIList);
}
if (showComment)
{
setupCaseComments(aCase, CHIList);
}
if (showRCase)
{
setupReachOutCases(aCase, CHIList);
}
//Phani Emmanni on 04/14/
if (showAttach) {
setupAttachments(aCase, CHIList);
}

}
filterByKeyword();
caseHistoryUtil.sortList(CHIlist,sortField,order);
}

public pageReference previewPDF()
{
PageReference pdf = Page.caseHistoryPDF;

return pdf;
}

public pageReference sendEmail()
{
if(sendToCaseContact && showPrivate)
{
apexPages.addMessage(new apexPages.Message(apexPages.severity.ERROR,'There was an error with your request. Please try to send your email again.'));
showPrivate = false;
refreshHistory();
return null;
}


Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();

PageReference pdf = page.caseHistoryPDF;

Blob b = pdf.getContent();

Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName('CaseHistory.pdf');
efa.setBody(b);

list<string> toAddresses = new list<string>();
if(sendToCaseContact && acase.Contact.Email != Null && acase.IsVisibleInSelfService)toAddresses.add(acase.Contact.Email);

list<string> additionalToList = new list<string>();

if(additionalTo != Null)
{
additionalToList = additionalTo.split(';', 0);

for(string s:additionalToList)
{
if(s.trim()!='')toAddresses.add(s);
}

}

list<string> bccAddresses = new list<string>();
if(bccOwner && aCase.Owner.Email != null)
bccAddresses.add(aCase.Owner.Email);

email.setSubject(emailSubject);
email.setToAddresses(toAddresses);
email.setBccAddresses(bccAddresses);
email.setPlainTextBody(emailBody);
email.setFileAttachments(new Messaging.Emailfileattachment[]{efa});
try
{
Messaging.Sendemailresult[] r= Messaging.SendEmail(new messaging.Singleemailmessage[]{email});
}
catch(exception e)
{
apexpages.addmessages(e);
return null;
}

apexPages.addMessage(new apexPages.Message(apexPages.severity.CONFIRM,'Your message has been sent.'));

string toString = 'to: ';
for(string s:toAddresses)
toString += (s + '; ');
toString += '\n';

string bccString = 'bcc: ';
for(string s:bccAddresses)
bccString += (s + '; ');
bccString += '\n\n';

Task newTask = new Task(
Description = toString + bccString + email.plainTextBody,
Priority = 'Normal',
Status = 'Completed',
Subject = 'Email: ' + email.Subject,
ActivityDate = System.Today(),
Whatid = acase.id
);

if(sendToCaseContact)newTask.whoId = aCase.ContactId;

insert newTask;

attachment a = new attachment(
body=b
,name = 'CaseHistory.pdf'
,parentId = newTask.Id
);

insert a;

pageReference pageRef = page.caseHistory;

pageRef.getParameters().put('id',caseId);

return pageRef;
}

public void filterByKeyword()
{
if(filterString != Null && filterString.length()>1)
{
string filter = filterString.tolowercase();

list<caseHistoryItem> temp = new list<caseHistoryItem>();

for(casehistoryitem i: CHIList)
{
boolean keep = false;

if(i.subject != Null)
{
string subject = i.subject.tolowercase();

if(subject.contains(filter))keep = true;
}

if(i.taskDescription != Null)
{
string description = i.taskDescription.tolowercase();

if(description.contains(filter))keep = true;
}

if(i.itemTypeName == 'Reachout Case' && rCaseSortMethod == 'separate')
{
list<caseHistoryItem> rTemp = new list<caseHistoryItem>();

for(casehistoryitem ri: i.rCaseCHIList)
{
boolean rKeep = false;

if(ri.subject != Null)
{
string rSubject = ri.subject.tolowercase();

if(rSubject.contains(filter))rKeep = true;
}

if(ri.taskDescription != Null)
{
string rDescription = ri.taskDescription.tolowercase();

if(rDescription.contains(filter))rKeep = true;
}

if(rKeep)
{
rTemp.add(ri);
keep = true;
}
}
i.rCaseCHIList = rTemp;
}

if(keep)temp.add(i);
}

CHIList = temp;
}

}

public void doSort() {
order = 'desc';

/*This checks to see if the same header was click two times in a row, if so
it switches the order.*/
if(previousSortField == sortField){
order = 'asc';
previousSortField = null;
} else {
previousSortField = sortField;
}

caseHistoryUtil.sortList(listIndex.get(listIndexInt),sortField,order);
}

public void setupHistories(Case c, list<caseHistoryItem>tList){
list<CaseHistory> cHistories = c.Histories;
String subject;
String oldVal;
String newVal;

setupPrefix();

for (CaseHistory ch:cHistories){
oldVal=String.valueOf(ch.oldValue);
newVal=String.valueOf(ch.newValue);

if(isId(oldVal)||isId(newVal))
subject=null;
else if(ch.OldValue==null&&ch.NewValue==null)
subject = ch.Field+'--Modified, or Created';
else if(ch.OldValue==null)
subject = ch.Field+' changed or set to '+newVal;
else if(ch.newValue==null)
subject = ch.Field+' changed or set to '+oldVal;
else{
subject = ch.Field+' changed from '+oldVal+' to '+newVal;
}


if(subject!=null)
tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, ch.CreatedDate, subject, ch.CreatedBy.Name, ch.CreatedById, null, 'History', null, null, null, null,false,null,null,null));
}
}

public void setupEmails(Case c, list<caseHistoryItem>tList){
tasks = c.Tasks;
for (task t: tasks){
tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, t.CreatedDate, t.Subject, t.CreatedBy.Name, t.CreatedById, t.Id, 'Email', t.ActivityDate, t.Owner.Name, '-- '+t.Description, t.OwnerId, t.isVisibleInSelfService,null,t,null));
}
}

private void setupPrefix(){
prefixSet=new Set<String>();
map<String, Schema.SObjectType> gD = Schema.getGlobalDescribe();
Set<String>keys=gD.keySet();
for(String key:keys){
Schema.DescribeSObjectResult r = gD.get(key).getDescribe();
if(r!=null &&r.getKeyPrefix()!=null && r.getKeyPrefix()!='')
prefixSet.add(r.getKeyPrefix());
}
}

public boolean isId(String at){
if(at==null)
return false;
else if(at.length()<5)
return false;
else{
String testVal = at.substring(0,3);
for(String prefix : prefixSet){
if(prefix.equals(testVal))
return true;
}
}
return false;
}

public void setupCaseComments(Case c, list<caseHistoryItem>tList)
{
String METHODNAME = CLASSNAME.replace('@@METHODNAME','setupCaseComments');

list <CaseComment> cComments = new list<CaseComment>();
List<CaseComment> cclist = new List<CaseComment>([Select Id,parentId,isPublished,CreatedDate,CommentBody,CreatedById,CreatedBy.Name from CaseComment c where parentId = :c.Id]);
for(CaseComment cc : cclist){
cComments.add(cc);
}

//for(CaseComment cc : c.CaseComments)cComments.add(cc);

for(CaseComment cc: cComments){

//System.debug('--------------------------->' + cc.isPublished);
System.debug(LoggingLevel.INFO, METHODNAME + ' :: cc.isPublished = ' + cc.isPublished +'\n\n');

tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, cc.CreatedDate, cc.CommentBody, cc.CreatedBy.Name, cc.CreatedById, null,'Comment', null, null, null, null,cc.IsPublished,cc,null,null));
}
}

public void setupReachOutCases(Case c, list<caseHistoryItem>tList){
Case[] cases = c.ReachOutCases__r;
for (Case r: cases){
list<CaseHistoryItem> CHItems = new list<CaseHistoryItem>();
if(rCaseSortMethod == 'integrate')CHItems = CHIlist;
integer indexSize = listIndex.keyset().size();
listIndex.put(indexSize,CHItems);
case rCase = queryCase(r.id);
CaseHistoryItem CHItem = new CaseHistoryItem(c.CaseNumber, c.Id, rCase.CreatedDate, rCase.Subject, rCase.CreatedBy.Name, rCase.CreatedById, rCase.Id, 'Reachout Case', null, rCase.Owner.Name, '-- '+rCase.Description, rCase.OwnerId, rCase.isVisibleinSelfService,null,null,rCase);

if (showPrivate)
{
if (showEmail)
{
setupEmails(rCase, CHItems);
}
if (showComment)
{
setupCaseComments(rCase, CHItems);
}
if (showHist)
{
setupHistories(rCase, CHItems);
}
if (showAttach)
{
setupAttachments(rCase, CHItems);
}
}
else
{
if (showEmail)
{
setupEmails(rCase, CHItems);
}
if (showComment)
{
setupCaseComments(rCase, CHItems);
}
}


if(rCaseSortMethod == 'separate')
{
caseHistoryUtil.sortList(CHItems,sortField,order);
CHItem.listIndex = indexSize;
CHItem.rCaseCHIList = CHItems;
}

system.debug('CHITEMS----------------------->>>' + CHItems);

tList.add(CHItem);
}
}


public void setupAttachments(Case c, list<caseHistoryItem>tList){
String METHODNAME = CLASSNAME.replace('@@METHODNAME','setupCaseComments');

list <Attachment> attmnts = new list<Attachment>();
list <Attachment> atts = new list<Attachment>([Select Id, parentId, OwnerId, Name, CreatedDate, CreatedById, CreatedBy.Name, Owner.Name from Attachment c where parentId = :c.Id]);

for(Attachment aa : atts){
attmnts.add(aa);
}
for (Attachment a: attmnts){
System.debug(LoggingLevel.INFO, METHODNAME + ' :: a.Name = ' + a.Name +'\n\n');
tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, a.CreatedDate, a.Name, a.CreatedBy.Name, a.CreatedById, a.Id, 'Attachment', null, a.Owner.Name, '-- ', a.OwnerId,false,null,null,null));
}
}

Hello all,

 

I am using a controller to update contact details. It's saved successfully but My Error Message was not printed.

 

Here's code,

 

public pageReference SubmitUserDetails()
{

Contact contact = [Select  .....all query.......];

contact.phone = '123';

update contact;

 

ApexPages.Message apexMessage = new ApexPages.Message(ApexPages.Severity.Error, 'Your changes saved  successfully');

ApexPages.addMessage(apexMessage);

 

PageReference pageReference = new PageReference('/ContactPage?VolId='+VolSelected);

//  VolSelected is a contact Id.
return pageReference;

}

 

Here's is page tag,

 

<apex:Messages  />  &  <apex:pageMessages />.

 

I have used both one by one but its not working. Could anybody help me to get through this.

 

Thanks in advance.

 

Pratty

  • March 15, 2012
  • Like
  • 0

Hi,

I am trying to fetch some Lead records from ORG1  and if some condition is satisfied create records in org2  from my current org.

 

I have credential of both ORGs .

 

list<Record> records = new list<Record>();

SFConnectionController controller = new SFConnectionController();

// First org from where I am fetching Lead records
LoginResult loginResult = controller.login(firstOrgUsername, firstOrgPassword, securityToken);
if(!loginResult.isError)
{
   Response response = controller.query('select Name from Lead, loginResult);

  records = response.data.records;

  if(/*somecondition*/)
 {
   // Second org where I want to insert record 
      LoginResult loginResultPublishingOrg = controller.login(secondOrgUserNmme, secondOrgPassword, securityToken);
   // here I want to insert record - I am not sure is it right syntax or not - Subscribe_User__c is object in second org
      Response response_insert = controller.query('Insert into Subscribe_User__c (User_Name__c)values ('Harshala')', loginResultPublishingOrg);
	
   /**** Getting error in response


 }
}

 

Received following error :

response_insert:Response:[data=Result:[fields={}, records=()], isError=true, message=Query Failed, result=<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>sf:MALFORMED_QUERY</faultcode><faultstring>MALFORMED_QUERY: unexpected token: Insert</faultstring><detail><sf:MalformedQueryFault xsi:type="sf:MalformedQueryFault"><sf:exceptionCode>MALFORMED_QUERY</sf:exceptionCode><sf:exceptionMessage>unexpected token: Insert</sf:exceptionMessage><sf:row>1</sf:row><sf:column>0</sf:column></sf:MalformedQueryFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>, status=Internal Server Error, statusCode=500]

 

Help me to insert record in ORG2... not getting where I am missing point. :(