• chiruganta
  • NEWBIE
  • 20 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 21
    Replies
Hi,

I need help on replacing reserved keywords with other values in my JSON response string. I have tried with replace and replaceAll methods, but​ I am getting error (System.LimitException: Regex too complicated) because of large JSON response.

Can someone help me  on this issue?​​
Hi,

I have verified an email in organization wide email address and sending email from apex class. This is working fine. But for one user it is throwing following exception,


System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address: []

 
Hi,

I have a requirement that need to send a record for approval from apex class without email notiifcation. But it need to send email from standard "Send for Approval" button. Please help me on this.
Hi,

I have a requirement that email sent from apex class is need to set from addresss as Lead owner. In my org there are number of users, so, we can't add all those users in Organization-wide-address. So how can I set the from address(Name and email) ?
Hi,
I have a requirement that whenever an account team member record is created we need to create a new record in other object. But I am not able to write Trigger on AccountTeamMember object. Please help me on this requirement.
I need help on showing list of user licences in Visualforce Page. Is this possible? If yes, please send me the steps to follow.
Hi,
I have a daily scheduled batch class. But while execution it is throwing "Internal Salesforce Error". Can anyone help me on this. Here is my source code and getting error at highlighted line.

global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator('Select Id from User where IsActive = true');  
   }
    
   global void execute(Database.BatchableContext BC, List<sObject> scope){  
      for(sobject s : scope){         
         User userRec = (User)s; 
         
         List<Campaign_User__c> campUserList = [Select Campaign__c from Campaign_User__c where User__c =: userRec.Id limit 10000];          
         
         Set<Id> campUserIds = new Set<Id>(); 
         for(Campaign_User__c CU: campUserList)
         {
             campUserIds.add(CU.Campaign__c);
         }
         
         List<Member__c> updatemembList = new List<Member__c>();  
         
         String buyerRecordTypeId = Schema.Sobjecttype.Account.getRecordTypeInfosByName().get('Buyer').getRecordTypeId();
         
         //Map<id,account> aMap = new Map<id,account>([Select Id,Name from Account where recordTypeId =: buyerRecordTypeId AND Camp_Rec_Count__c > 0 limit 50000]);
         List<account> acctList = [Select Id,Name from Account where recordTypeId =: buyerRecordTypeId AND Camp_Rec_Count__c > 0 limit 20000];        
         Set<id> accIds = new Set<id>();
         for(Account acc : acctList)
         {
             accIds.add(acc.Id);
         }
         
        // Map<id,Campaign__c> cMap = new Map<id,Campaign__c>();
         List<Campaign__c> campList =[Select Id, Name, Accounts__c,Campaign_Project__c,Accounts__r.Name from Campaign__c where Id in: campUserIds AND Accounts__c in: accIds AND Type__c = 'Telemarketing' order by createdDate Desc limit 25000];        
         Set<id> campIds = new Set<id>();
         for(Campaign__c camp: campList)
         {
             campIds.add(camp.id);
         }
         
         List<Member__c> membList = [Select Id, Status__c, Company__c, Contact__c, Contact__r.AccountId, Assigned_Date__c, Campaign__c from Member__c where Campaign__c in: campIds AND Status__c != 'Assigned' AND Status__c != 'Closed' ORDER BY Assigned_Date__c Desc limit 20000];
         
         List<Task> openTasks = [Select Id from Task where OwnerId =: userRec.Id AND Campaign_Member_Id__c != null AND Status != 'Completed' limit 200];
         
         Integer recCount = openTasks.size();
         
         recCount  = 200 - recCount;
Hi,

I have a problem in scheduled batch class. Some day it is executing and some days it is saying "Internal Salesforce Error". Can anyone help on this issue?
Hi,

I need help on showing visualforce page as excel I tried it using contenttype="application/vnd.ms-excel. But when I opened it, it will download as excel file automatically. I need view instead of download page. Please someone help me on this. 
I need help on using Sencha in visualforce page. I need to show sencha calendar in VF page.
I need help on calculating the number of hours spent on each task without installing AppExchange app.
We are planning a AppExchange app for partner users. I need some information on this limitations.
I need to change the territory of an account in apex class/ trigger. Is it possible? If yes, Please help me on this.
Is it possible to change the Territory of an account? If yes, please help me.
Hi, I have a requirement that when an opportunity is in Closed won satge the territory of that account need to be restrictd ()? Is it possible to restrict using trigger? If yes, please help me.

hi every one,

i dont know java script much,

here i used check box,

if i select top most one , it selects all options but the problem is if i unselect any one of the option, the top most check box should be unselected,

please help,

 

<script>
  function checkAll(cb)
  {
 var inputElem = document.getElementsByTagName("input");
  for(var i=0; i<inputElem.length; i++)
  {
  if(inputElem[i].id.indexOf("checkedone")!=-1)
  inputElem[i].checked = cb.checked;
  }
  }   
  </script>

I want to  link salesforce account with online forms to update account information in real time.

 

For This I want to,

 

Develop PHP component capable of communicating with Salesforce and pulling down address data.

 

Develop a WordPress plugin that can be easily configured with salesforce login information, a schedule of when a sync should automatically happen, and a button to "manually sync."

 

 Please Can Anyone help on this?

Hi,

I have verified an email in organization wide email address and sending email from apex class. This is working fine. But for one user it is throwing following exception,


System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address: []

 
I need to change the territory of an account in apex class/ trigger. Is it possible? If yes, Please help me on this.

I want to  link salesforce account with online forms to update account information in real time.

 

For This I want to,

 

Develop PHP component capable of communicating with Salesforce and pulling down address data.

 

Develop a WordPress plugin that can be easily configured with salesforce login information, a schedule of when a sync should automatically happen, and a button to "manually sync."

 

 Please Can Anyone help on this?

Hi,

I have verified an email in organization wide email address and sending email from apex class. This is working fine. But for one user it is throwing following exception,


System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address: []

 
Hi,

I have a requirement that email sent from apex class is need to set from addresss as Lead owner. In my org there are number of users, so, we can't add all those users in Organization-wide-address. So how can I set the from address(Name and email) ?
I need help on showing list of user licences in Visualforce Page. Is this possible? If yes, please send me the steps to follow.
We are planning a AppExchange app for partner users. I need some information on this limitations.
I need to change the territory of an account in apex class/ trigger. Is it possible? If yes, Please help me on this.
Is it possible to change the Territory of an account? If yes, please help me.
Hi, I have a requirement that when an opportunity is in Closed won satge the territory of that account need to be restrictd ()? Is it possible to restrict using trigger? If yes, please help me.

Hi,

 

I have a visualforce page. Where it accepts opportunities (20 opportunities) .

I have used inputfield for this to accept opportunities.I am storing first 10 opportunties in str1 and 2nd 10  in str2 (with comma seperated values in each of the strings).

 

These are getting saved in the opportunity table in str1 and str2 columns. But when I refresh the page I dont see the values which I stored in the earlier run in the VF page. I mean the values which are stored are not displayed.

 

My requirement is when I come to the page newly/refresh the page I need to see the values which I stored earlier and I need to edit them (if needed).

 

VF Page:

 

    <apex:page standardController="Opportunity" extensions="VisualForceBigOpportunityExtension" title="Edit Big Opportunity">
    <apex:sectionHeader title="Edit Big Opportunitys"/><apex:pageMessages ></apex:pageMessages>
        <apex:form >
        <apex:pageBlock title="Big Opportunitys" mode="detail">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Big Opportunitys" collapsible="true" columns="1">
                <apex:pageBlockTable value="{!BigOpportunity}" var="BigOpportunity" columns="2">
                  <apex:column headerValue="Opportunity">
                        <apex:inputField value="{!BigOpportunity.Opportunity1__c}"/>
                 </apex:column>
                 <apex:column headerValue="Opportunity">
                        <apex:inputField value="{!BigOpportunity.Opportunity2__c}"/>
                 </apex:column>
       </apex:pageBlockTable>
     </apex:page>          

 

Please let me know where I am missing things.

 

Thanks,

JBabu.

 

 

  • June 14, 2012
  • Like
  • 0

Hi 

  I am not able to dispaly  error message on VF page 

  My code : 

VF page 

<apex:page contr

<apex:pageMessages />

 

controller 

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error'));

 

can anybody help me to solve this problem.

 

Thanks

Anu

Hi All,

 

I have created a utility to merge records of any standard object (except user) and custom objects. User can select upto three records of any object to merge. User can select a Master record and also select the fields of child records. All the related objects can also be merged using that utility.

 

Thanks,
Devendra Natani (Salesforce Certified Developer)

Blog

 

 

Hi All,

 

I have posted some of the sample questions for 401 certification exam. Also how you can prepare for the exam.

Will soon post some more interesting topics related to certification exam.

 

Click for Smaple Questions

And How To Prepare

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Hi,

I am trying to create an AccountShare and AccountTeam record.

Requirement is: When an Account is created, Account has to be assigned to the Territory of the user who is creating the Account record. Also the user has to be added to the the AccountTeam for that particular Account. We are trying to achieve this using a Trigger and we are not using Assignment rules for lack of some feasibility reasons.

 

I have following two queries:

1. Is it possible to create AccountShare object or just it can be updated? When we try creating an AccountShare object it requests for all values of AccessLevel(Account,Opp,Case,Contact) fields and when provided with these values says AccessLevel cannot be below OWD for those objects though i am providing access above or same level as OWD for these objects.

 

2. i am trying to set RowCause field on AccountShare to TerritoryManual which i am unsuccessful becos it is a read only field. How can i set value for this field as i want to add the account to the territory of the user. Can the RowCause fied be updated for an exisitng AccountShare object in case we can't create AccountShare record as whenever an AccountTeam is created an entry is created in AccountShare.

 

Any help with this regard is appreciated. This is urgent!!

 

Thanks.

I just added a NameSpace to my Developer org, and now 2 tests fail with an awful error message.  I'm tempted to just remove the tests so I can actually upload the package.

 

The code hasn't changed, and tests still pass in installed orgs that have the unmanaged package.

 

Error debug lines:

 

21:18:53.48|USER_DEBUG|[7,9]|DEBUG|query string: Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c WHERE scheduledUnfollowDate__c<= TODAY AND IsDeleted=FALSE
21:18:53.48|METHOD_EXIT|[7,9]|system.debug(String)
21:18:53.48|METHOD_ENTRY|[8,52]|database.query(String)
21:18:53.48|SOQL_EXECUTE_BEGIN|[8,52]|Aggregations:0|Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c WHERE scheduledUnfollowDate__c<= TODAY AND IsDeleted=FALSE
21:18:53.51|SOQL_EXECUTE_END|[8,52]|Rows:3
21:18:53.51|METHOD_EXIT|[8,52]|database.query(String)
21:18:53.51|METHOD_ENTRY|[9,9]|system.debug(String)
21:18:53.51|METHOD_ENTRY|[9,31]|LIST<chttrunfollow__UnfollowQueue__c>.size()
21:18:53.52|METHOD_EXIT|[9,31]|LIST<chttrunfollow__UnfollowQueue__c>.size()
21:18:53.52|USER_DEBUG|[9,9]|DEBUG|size: 3
21:18:53.52|METHOD_EXIT|[9,9]|system.debug(String)
21:18:53.52|METHOD_ENTRY|[10,16]|Database.getQueryLocator(String)
21:18:53.52|SOQL_EXECUTE_BEGIN|[10,16]|Aggregations:0|Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c
21:18:53.77|SOQL_EXECUTE_END|[10,16]|Rows:3
21:18:53.77|METHOD_EXIT|[10,16]|Database.getQueryLocator(String)
21:18:53.105|FATAL_ERROR|Internal Salesforce.com Error

 I saw this thread, and added my namespace, but no luck:

http://community.salesforce.com/t5/Visualforce-Development/Visualforce-An-internal-server-error-has-occurred/m-p/167376

 

Class that produces the above error:

 

global with sharing class UnfollowProcessUnfollowQueueBatch implements Database.Batchable<sObject>{

   global String sObjectQuery ='Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c WHERE scheduledUnfollowDate__c<= TODAY' ;
   
   global Database.QueryLocator start(Database.BatchableContext BC){
        system.debug('query string: '+sObjectQuery);
        List<chttrunfollow__UnfollowQueue__c> uq = database.query(sObjectQuery);
        system.debug('size: '+uq.size());
        return Database.getQueryLocator(sObjectQuery);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
        Set<Id> recordIds=new Set<Id>();
  
        for(sObject s : scope){
            recordIds.add(String.ValueOf(s.get('recordId__c')));
        }//for
    
        //This is the method that unfollows all people from the records 
        try{
            UnfollowRecords.UnfollowRecordsButtonAction(recordIds);
            delete scope;
        } catch (Exception e) {
        }//try
   }

   global void finish(Database.BatchableContext BC){
       AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email from AsyncApexJob where Id =:BC.getJobId()];
  }

}//UnfollowRecordsFromDelayQueueBatch

Other Class that calls this class:

 

global with sharing class unfollowTryBatchJobsAgain{

    public static void unfollowTryBatchJobsAgain(){
        Integer numBatchApexJobsLimit=5;//at time of coding, there are at most 5 concurrent batch apex jobs in any org
        List<AsyncApexJob> numBatchJobs = [SELECT Id, Status FROM AsyncApexJob WHERE Status = 'Queued' OR Status = 'Processing'];

        //This is the number of jobs that can be queued up by this method
        Integer numJobsAvailable=numBatchApexJobsLimit - numBatchJobs.size();

        if(numJobsAvailable>0){
            List<UnfollowBatchJobsQueue__c> batchJobsQueued=[SELECT Id, IsDeleted, delayJob__c, delayRulesIncluded__c, evalateEachRecordForDaysDelay__c, numRulesUsedInThisObject__c, objectName__c, sObjectQuery__c FROM UnfollowBatchJobsQueue__c WHERE IsDeleted=FALSE ORDER BY  CreatedDate ASC];
            //Goal here is to process the delay queue first as it's more important than the others. Rather than do 2 queries, it's handled with variables here:
            Integer delayJobNum=1000;//initialize to huge number as a backup
            for (Integer i=0;i<batchJobsQueued.size();i++){
                if (batchJobsQueued[i].delayJob__c==TRUE){
                    delayJobNum=i;
                    break;
                }//if 2
            }//for 1
            
            for(Integer i=0; i<numJobsAvailable && i<batchJobsQueued.size(); i++){
                //if this is the high priority "delayed records scheduled for unfollow today" job, do it first
                if (delayJobNum!=1000){
                    UnfollowProcessUnfollowQueueBatch unfollowDelayedRecords= new UnfollowProcessUnfollowQueueBatch();
                    unfollowDelayedRecords.sObjectQuery=batchJobsQueued[delayJobNum].sObjectQuery__c;
                    try{
                        Id unfollowRulesProcessId = Database.executeBatch(unfollowDelayedRecords, 200); 
                        delete batchJobsQueued[delayJobNum];
                    } catch(exception e){
//                        system.debug('Either the batch failed or the job deletion from teh queue failed: '+e);
                    }//try
                } else if(batchJobsQueued[i].delayRulesIncluded__c==FALSE){
                 //is this the simple case with no "days delay" rules?
                    UnfollowRecordsBatch  unfollowRecords= new UnfollowRecordsBatch();
                    unfollowRecords.ObjectName=batchJobsQueued[i].objectName__c;
                    unfollowRecords.numRulesUsedInThisObject=batchJobsQueued[i].numRulesUsedInThisObject__c.intValue();
                    unfollowRecords.sObjectQuery =  batchJobsQueued[i].sObjectQuery__c;
                
                    try{
                        Id unfollowRulesProcessId = Database.executeBatch(unfollowRecords, 200); 
                        delete batchJobsQueued[i];
                    } catch(exception e){
//                        system.debug('Either the batch failed or the job deletion from the queue failed: '+e);
                    }//try
                } else {
                //else it's the more complex case where we need to check for the unfollow date
                    UnfollowQueueDelayRecordsBatch queueDelayRecords= new UnfollowQueueDelayRecordsBatch();
                    queueDelayRecords.ObjectName=batchJobsQueued[i].objectName__c;
                    queueDelayRecords.sObjectQuery =  batchJobsQueued[i].sObjectQuery__c;
                    queueDelayRecords.evalateEachRecordForDaysDelay=batchJobsQueued[i].evalateEachRecordForDaysDelay__c;
                    if(queueDelayRecords.evalateEachRecordForDaysDelay==TRUE){
//let's cross our fingers that the rule criteria didn't change between when this job first ran and now :(  
//Will the code fail elegantly if the rules were changed?
//I'd rather not create a 3rd queue just to save the state of the rules due to stupid batch apex limits
                        queueDelayRecords.delayRules=[Select Id, ObjectName__c, Active__c, FieldName__c, FieldType__c, Operator__c, Value__c, DaysDelay__c FROM UnfollowRule__c WHERE DaysDelay__c>0 AND Active__c = TRUE AND objectName__c=:queueDelayRecords.ObjectName]; 
                    }//if 3

                    try{
                        Id unfollowRulesProcessId = Database.executeBatch(queueDelayRecords, 200); 
                        delete batchJobsQueued[i];
                    } catch(exception e){
//                        system.debug('Either the batch failed or the job deletion from the queue failed: '+e);
                    }//try
                }//if 2
            }//for 1
        }//if 1
        
/*                        
        //This will store the job definition for the jobs over the numBatchApexJobsLimit to be run later
        List<UnfollowBatchJobsQueue__c> batchJobsQueued=new List<UnfollowBatchJobsQueue__c>();

        List<UnfollowRule__c> activeNonDelayedRules=[Select Id, ObjectName__c, Active__c, FieldName__c, FieldType__c, Operator__c, Value__c, DaysDelay__c FROM UnfollowRule__c WHERE (DaysDelay__c<1 OR DaysDelay__c=null) AND Active__c = TRUE];
        
        //now count the # rules for each object to pass into the email later
        For (UnfollowRule__c rule:activeNonDelayedRules){
            List<UnfollowRule__c> rules=new List<UnfollowRule__c>();
            if(objectRulesMap.containsKey(rule.ObjectName__c)){
                //get the existing rules in the map & add the new one
                rules=objectRulesMap.get(rule.ObjectName__c);
                rules.add(rule);
                objectRulesMap.remove(rule.ObjectName__c);
                objectRulesMap.put(rule.ObjectName__c, rules);
            } else {
                rules.add(rule);
                objectRulesMap.put(rule.ObjectName__c,rules);
            }//if 1
        }//for 1

        //Now queue up all the batch jobs
        for (String objectName:objectRulesMap.keyset()){
            //First check if there's a slot available - max of 5 concurrent jobs across all apps
            addFieldNames=FALSE;            
            query=buildQuery(objectName, objectRulesMap.get(objectName), addFieldNames);
            if(numJobsAvailable>0){
                numJobsAvailable--;//subtract one from the limit
                UnfollowRecordsBatch  unfollowRecords= new UnfollowRecordsBatch();
                unfollowRecords.ObjectName=objectName;
    
                unfollowRecords.numRulesUsedInThisObject=objectRulesMap.get(objectName).size();
                unfollowRecords.sObjectQuery =  query;
//                system.debug('The sObjectQuery string is: '+unfollowRecords.sObjectQuery);
                
                Id unfollowRulesProcessId = Database.executeBatch(unfollowRecords, 200); 
            }else{
                String sObjectQuery = query;
//                system.debug('There are 5 batch jobs already running, so this job is not scheduled.  Delay Job: TRUE, Object: '+objectName+', # Rules: '+objectRulesMap.get(objectName).size()+', Query: '+sObjectQuery );
                UnfollowBatchJobsQueue__c job=new UnfollowBatchJobsQueue__c(delayJob__c=FALSE, delayRulesIncluded__c=FALSE, objectName__c=objectName, numRulesUsedInThisObject__c=objectRulesMap.get(objectName).size(), sObjectQuery__c=sObjectQuery);
                batchJobsQueued.add(job);
            }//if 1
        }//for 1
        try{
            if(batchJobsQueued.size()>0){
                insert batchJobsQueued;
            }//if 1
        }catch (DMLException e){
//            system.debug('The batch jobs were not added to the queue successfully, likely due to dupe object name.  Error: '+e);
        }//try
*/        
    }//unfollowTryBatchJobsAgain
}//unfollowTryBatchJobsAgain

 

 

 

 

I realize that the DMO Options do not apply to Accounts or Territories, however I am still looking for a good way to assign a Territory to an Account in APEX.

 

Currently we have an assignment rule which assigns the Territory to the Account where the Territory Name matches a Picklist value in the Account. I figured that if I set the Picklist value in APEX and update the Account, the assignment rule should catch it - apparently not - although updating the account again (changing no values) directly in SF does call the assignment rule and attaches the Territory as expected. I'm guessing that running the update Account command twice in APEX won't work either.

 

Since Workflows are evaluated after the Assignment Rules, I don't think a workflow based on the picklist value will work.

 

So, would creating an AccountShare record connecting the Account to the Group that is related to the Territory do the trick??  This is based on the likely mistaken premise that a Territory attached to an Account represents the AccountShare rule that was created - create the AccountShare, and the Territory is connected and should show up in the Account. Seems like flawed thinking to me, but I'm not sure why.

 

I know I'm not the first to encounter this, so I'm hoping someone out there might have the best solution for this.

 

Thanks

 

ODB

How do I query the Territories that are associated with an Account?  I found another thread that mentioned the AccountShare object, but I don't see how that helps...

Thanks
Chris
  • August 05, 2008
  • Like
  • 0