• Saikishore Reddy Aengareddy
  • SMARTIE
  • 1639 Points
  • Member since 2011
  • Salesforce Consultant
  • Prospance Inc


  • Chatter
    Feed
  • 60
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 246
    Replies

On the Content object page I can see it dispalyed in Kb or other sizes, but when I display the contentsize field on a Visualforce page it shows the size in bytes.  I would like it to appear as Kb, Mb, or Gb.  A contractor had used some JavaScript to calcuate the size on another page, but I'd rather not use JavaScript as I'd like to try and stay server side instead of client side.  What are my options?  Do I use forumula on a second hidden field, is there some Visualforce tag I can use? 


Apex Trigger to Populate Custom Field of type Lookup in Opportunity Object with Account Owner from Account Object,how can i achieve this
Hi,

I have an aggregate result query that is working, but I need to add another paramenter so I can get the query AND the Id of the Account I'm querying.  But I can't figure out how to do it.  If I add the Id field I get an error.

Thanks,
 
public List<AcctSumList> getAccountSummary60() {
        list<AcctSumList> acctSummary = new List<AcctSumList>();
        List<AggregateResult> getList = [SELECT Account.Name acctName, sum(amount) TotalAmount 
                                         FROM Opportunity 
                                 		 WHERE (Account.OwnerId =: UserId OR
                                         Account.Client_Specialist_1__c =:UserId OR
                                         Account.Client_Specialist_2__c =:UserId OR
                                         Account.Client_Executive__c =:UserId) 
                                         AND StageName='B. Decision Due' AND CloseDate = THIS_Quarter
                                         GROUP BY Account.Name ORDER BY sum(amount) DESC LIMIT 10];
        for(AggregateResult agg : getList) {
            String AccountName = (string)agg.get('acctName');
             Double TotalAmount = (double)agg.get('TotalAmount');
            acctSummary.add(new AcctSumList(AccountName, TotalAmount));
        }
        return acctSummary;
    }

 
I was hoping to use a visualforce page to display a banner type message at the top of account records, what I have is below:

<apex:page standardController="Account" sidebar="false" showHeader="false" showChat="false"> <apex:pageMessage summary="Testing" severity="warning" strength="3" rendered="{!Account.custom_field_c <> NULL}" /> </apex:page>

But instead of displaying "Testing" I want it to display the text in the custom_field_c. Is that possible?

Thanks for any help! I haven't done anything with apex or visualforce before.
 
  • February 17, 2015
  • Like
  • 0
i am trying to update a field on Lead object based on activity. Here is the code. When i create an acitvity on leads this field remain blank. Am i missing something. 
trigger UpdateLeadCounts on Task (after delete, after insert, after undelete, after update) {

set<ID> LeadIds= new Set<ID>();
for(Task tt:trigger.new)
{
if(tt.whoId!=null && string.valueof(tt.WhoId).startsWith('003'))
{

LeadIDs.add(tt.whoID);
}
}

if(LeadIds.isEmpty())
return;
List<Lead> cnts= new List<Lead>();

Integer number1=1;
for(Lead ct:[select id, name, count1__c from Lead where id in:Leadids])
{

if(ct.count1__c ==null)
ct.count1__c=0;

ct.count1__c=ct.count1__c+number1;


cnts.add(ct);
}

if(cnts.size()>0)
{
update cnts;
}
}
 

Hello, I'm quite new to the bulkifying idea and need to bulkify the following sinmple trigger, which just updates a field on a parent object:

 

trigger Approval_Actions on Approval__c (after update) {
    List<Approval__c> app = trigger.new;
    Opportunity opp = [select Approval_Date__c from Opportunity where Id =: app[0].Opportunity__c LIMIT 1];
    if(app[0].Status__c == 'Approval GRANTED'){
       opp.Approval_Date__c = date.today();
    }
    update opp;
}

 

The problem is: how to bulkify it without having an SQL query in a loop?

public with sharing class Alert {  
	
	@future
	public static void processCustomAccounts(list<String> names, Map<String,String> alert) {
		
          
          // list to store the custom accounts to update
          List<CustomAccount__c> customaccountsToUpdate = new List<CustomAccount__c>();
            
          // iterate through the list of custom accounts to process
          for (CustomAccount__c a : [Select Id, Name,Alert__c From CustomAccount__c where Name like :names]) {
               string [] truncateagain = a.Name.split('-'); 
               string tpart1 = truncateagain.get(0);
               string tpart2 = truncateagain.get(1);
               string addfirsttwoparts = tpart1 + '-' + tPart2 + '%';
               
               // if alert value in the map passed in the method above is not null
			   // replace all existing custom accounts with this new value.
			   if(alert.values()!=null){
                             	a.Alert__c = alert.get(addfirsttwoparts);
               } 
			   // if alert value in the map passed in the method above is null
			   // make this null value as the value of the 1st record found in the SOQL			   
			   else if(alert.values()==null){
               	
               	id myalert = a[0].Alert__c;   // error: expression must be a list type: SOBJECT:CustomAccount__c               	a.Alert__c = myalert;
               	system.debug('now what!!!!!!!');
               	
               	
               	}
               // add the custom accounts to the list to update
               customaccountsToUpdate.add(a);
          }
          
                   AlertProcessorControl.inFutureContext = true;
                    
          if(!customaccountsToUpdate.isEmpty()){
          	update customaccountsToUpdate;
          }
    }
}

 

Hi!

I need to invoke a WS when an user update an Account.

 

I had thought in calling the ws inside a trigger, but I'm getting the next exception : 

System.CalloutException: Callout from triggers are currently not supported.

 

Could you give me some tips for solving that inconvenience?

 

 

Thanks in advance

 

I have written a trigger to prevent the creation of new accounts, and it works fine via UI but not via Lead Convert tool. Any ideas?

I eventually will add a filter so restrict a certain set of users (by profile) to not be able to create accounts but just testing it in a simple format to see if the account creation prevention works but it is not working when new accounts get created via lead conversion process.Any ideas?

Here's my code:


 trigger PreventNewAcctCreation on Account (before insert) 
{
  for (Account act : Trigger.new)

  {
         act.addError('You do not have access to create new Accounts');
  }

}

Hello,

I have this Trigger that update the checkbox to true if an Opp has an attachment. This Trigger work fine.

 

trigger Att_Aft_Trig on Attachment (after insert, after update) 
 {
                        List<Opportunity> co = [select id, Attachement__c from Opportunity where id =: Trigger.New[0].ParentId];
                        if(co.size()>0)
                        {
                                    co[0].Attachement__c = true;
                                    update co;
                        }                                                                   
            
}

 

 

But I want to know if I remove the Attachment the checkbox should be unchecked?How should I do this in this trigger?

 

Thanks,

Shruti

Hello,

 

I have two triggers that pull information from a completed task, one puts that information on a contact record, one puts that information on a lead record based on the WhoId in the task record. The two triggers are written to be exactly the same. Below is the contact trigger.

 

trigger ContactLastCallResult on Task (after insert,after update)
{
String TSubject='Call';
String TResult='Completed';
String WType='003';
Map<Id, Contact> ContactIDMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
for (Task tk: Trigger.new)
{
Ids.add(tk.WhoId);
}
Map<id, Contact> ContactIDMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
for (Task t: Trigger.new)
if (t.subject.contains(TSubject) && t.status.contains(TResult) && t.WhoType__c.startsWith(WType))
{
Contact c = ContactIDMap2.get(t.WhoId);
c.Last_Call_Result__c = t.CallDisposition;
c.Last_Call_Date__c = t.Completed_Date__c;

ContactIDMap.put(c.id,c);
}
update ContactIDMap.values();
}

 

I put together a simple test class to simulate a task being created:

@isTest
private class WhoType_Test {

static TestMethod void Test0_TestCTaskInsert()
{
Task t = new Task();
t.Subject = 'Call';
t.whoid = '003f0000009ApEU';
t.calldisposition = 'contact';
t.status = 'completed';
t.completed_date__c = t.LastModifiedDate;
insert t;     
}
}

 

When I run the test, I get:

System.NullPointerException: Attempt to de-reference a null object

Trigger.ContactLastCallResult: line 17, column 1

 

Line 17 is:

c.Last_Call_Result__c = t.CallDisposition;

 

Anyone have any ideas?

 

Thanks,


Gus

 

  • September 30, 2013
  • Like
  • 0

I am attempting to populate the UPName__c field with the Parent ID of all of my Account records whose Parent has the X2_0_Ultimate_Parent_c field checked. I have put together this batch code : 

global class UltParentName implements Database.Batchable<sObject>{        
        //string query;
        string query = 'SELECT Id, Name,ParentID FROM Account WHERE Parent.X2_0_Ultimate_Parent__c = True';

        /*global UltParentName (string myQuery){      
            query = myQuery;        
        } */

        global Database.QueryLocator start(Database.BatchableContext BC){
            return Database.getQueryLocator(query);
        }

        global void execute(Database.BatchableContext BC,List<Account> scope) {
             List<Account> accns = new List<Account>();
             for(Account a : scope){
                   //Account a = (Account)s;
                   if(a.Parent.X2_0_Ultimate_Parent__c==True){
                         a.UPName__c=a.ParentID;
                         accns.add(a);
                   }
             }                  
             update accns;          
        }
        global void finish(Database.BatchableContext BC)
        {     //System.debug(LoggingLevel.WARN,'Batch Job Complete');
        }       
    }

 

I am running the following code through an Execute Anonymous in the developer console : 

UltParentName getuprecs = new UltParentName();
Database.executeBatch(getuprecs);

 When I run this in Executable Anonymous it runs through but it doesn't populate the UPName__c field with the Parent.ID. 

Can anybody see anything wrong with this ? 

Thank you very much.

 

  • September 26, 2013
  • Like
  • 0

Hi,

 

I need some help on creating trigger for attachment for case and workorder object.
I found the code to make all attachment as private before insert, but how can I make it work only for case and workordre object?

Which field can tell what object the attachment is being attached to?

 

Thank you,

trigger PrivateAttachment on Attachment (before insert) {
  for(Attachment record:Trigger.new)   {
      record.IsPrivate = TRUE;
   }
}

 

 

Hello,

 

I have a data structure of the type Map<String,Map<String,Decimal>>, which relates each customer to a list of bank accounts and their respective balances, as well as a total balance which would be the sum of all balances.

 

A sample line of this structure is something like the following:

 

"John" -> ("Bank 1" -> 1200.00, "Bank 2" -> 300.50, "Total" -> 1500.50)

 

I would like to sort this structure by the "Total" value. Can you please give me some ideas?

 

Thank you!

I am creating a custom clone button. If user is trying to clone a record which has record type for which he does not have access, i want dont want to pass record type id to url.

 

Please let me know how can we check in javascript if user has access to particular record type.

I have a table and the columns have outputlinks. Right now, if the column is empty, it displays "None" which is a link to nowhere. I want to be able to remove the link if the column is empty.  Any help? Thanks

 

I tried 

 

<apex:outputLink value="/{!object.field__c}" )}" disabled = {!IF(!object.field__c == '')}    target="_top">  

 Obviously didn't work since disabled takes in boolean. 

 

<apex:column >
   <apex:facet name="header" ><apex:outputText value="{!$Label.Name}" /></apex:facet>
       <apex:outputLink value="/{!object.field__c}" )}" target="_top">  
       <apex:outputField value="{!object.field__c}" />
       </apex:outputLink>
 </apex:column>  

 

  • September 19, 2013
  • Like
  • 0

Hi All,

      I have a requirement here. It says that for a given case look for its cert, and if that cert has multiple moratotriums then create new TimeLine records on that case.

 

Case---Look Up---->>Cert<<-----Look Up----Moratoriums

 

I have a code written below , just need to get a soql outside for loop. Please help

 

    if(Trigger.isAfter && Trigger.isInsert){
      List<Timeline_Entries__c> TimeLineList = new List<Timeline_Entries__c> ();
      List<Moratorium__c> MoratoriumList = new List<Moratorium__c>();
      
      for(Case cs:Trigger.new){
        MoratoriumList=[Select Name,Cert_No__c,Start_Date__c,Stop_Date__c from Moratorium__c where Cert_No__c=:cs.Cert_Number__c]  ;
          
          for (integer x=0;x<MoratoriumList.size();x++){
              integer count=0;
              // To compare moratorium x with others in list. Comparison always goes fwd. i.e x is compared with x+1, x+2 so on never with x-1
              for(integer z=x+1;z<MoratoriumList.size();z++){
                      count++;
                      
                      if((MoratoriumList[x].Start_Date__c>MoratoriumList[z].Start_Date__c)&&(MoratoriumList[x].Stop_Date__c>MoratoriumList[z].Stop_Date__c)&&(MoratoriumList[z].Stop_Date__c>MoratoriumList[x].Start_Date__c)){
                      
                      // Perform some action using components of x,z, current case i.e cs.Field__c       
                      }
                      else if((MoratoriumList[x].Start_Date__c<MoratoriumList[z].Start_Date__c)&&(MoratoriumList[x].Stop_Date__c<MoratoriumList[z].Stop_Date__c)&&(MoratoriumList[x].Stop_Date__c>MoratoriumList[z].Start_Date__c)){
                       // Perform some action using components of x,z, current case i.e cs.Field__c    
                      }
                      else if((MoratoriumList[x].Start_Date__c==MoratoriumList[z].Start_Date__c)&&(MoratoriumList[x].Stop_Date__c==MoratoriumList[z].Stop_Date__c)){
                       // Perform some action using components of x,z, current case i.e cs.Field__c    
                      }
                      else if((MoratoriumList[x].Start_Date__c<MoratoriumList[z].Start_Date__c)&&(MoratoriumList[x].Stop_Date__c>MoratoriumList[z].Stop_Date__c)){
                       // Perform some action using components of x,z, current case i.e cs.Field__c    
                      }
                      else if((MoratoriumList[x].Start_Date__c>MoratoriumList[z].Start_Date__c)&&(MoratoriumList[x].Stop_Date__c<MoratoriumList[z].Stop_Date__c)){
                       // Perform some action using components of x,z, current case i.e cs.Field__c   
                      }
                     else if(count==MoratoriumList.size()-1){
                       // Perform some action using components of x,z, current case i.e cs.Field__c    
                          
                      }
              }
        
           
           }
      }
    if(TimeLineList.size()>0){
     insert TimeLineList;
    }   
  }

Hi,

I have no idea where my error is, debug log message is "System.NullPointerException: Attempt to de-reference a null object"  and error titled "Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateContactsOnAddressChange: execution of BeforeInsert" 

 

I guess I'm confused because because of my trigger before insert and after update.

 

Any help appreciate it!

 

This is my trigger: 

trigger updateContactsOnAddressChange on Account (before Insert, after update) {
     
        // I want to find the new address/values on Account by map Id Keys 
         
        Map<Id, Account> acctsWithNewAddresses = new Map<Id, Account>();
     
        // Trigger.new holds my list of the Accounts that will be updated        
        // This loop iterates over the list, and adds any that have new
        // addresses to the acctsWithNewAddresses map. 
         
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            if (   (Trigger.old[i].BillingCity != Trigger.new[i].BillingCity)
                || (Trigger.old[i].BillingCountry != Trigger.new[i].BillingCountry)
                || (Trigger.old[i].BillingPostalCode != Trigger.new[i].BillingPostalCode)
                || (Trigger.old[i].BillingState != Trigger.new[i].BillingState)
                || (Trigger.old[i].BillingStreet != Trigger.new[i].BillingStreet))  {
                acctsWithNewAddresses.put(Trigger.old[i].id,Trigger.new[i]);
            }
        }
                         
        List<Contact> contacts = [SELECT id, accountid, MailingCity, MailingCountry, MailingPostalCode,MailingState, MailingStreet
                          FROM Contact
                          WHERE accountId in :acctsWithNewAddresses.keySet()];
            
                    List<Contact> updatedContacts = new List<Contact>();
     System.debug('Kellers ' + contacts);


        //iterating over each contact in Account
        for (Contact c : contacts) {
            Account parentAccount = acctsWithNewAddresses.get(c.accountId);
            c.MailingStreet = parentAccount.BillingStreet;
            c.MailingCity = parentAccount.BillingCity ;
            c.MailingCountry = parentAccount.BillingCountry ;
            c.MailingPostalCode = parentAccount.BillingPostalCode ;
            c.MailingState = parentAccount.BillingState ;
            c.MailingStreet = parentAccount.BillingStreet ;
    
     
         // Rather than insert the contacts individually, add the         
            // contacts to a list and bulk insert it. This makes the         
            // trigger run faster and allows us to avoid hitting the         
            // governor limit on DML statements 

            updatedContacts.add(c);
        }
        update updatedContacts;
    }

 This is my test: 

@isTest
public class TestUpdateContactsOnAddressChange{
    static testmethod void testAddressChange() {
       //create an account and create account address
        Account sAcct = new Account();
       	sAcct.Name = 'Test Account';
        sAcct.BillingStreet = '11 Initial Street'; 
        sAcct.BillingCity = 'Rochester';
        sAcct.BillingPostalCode = '12456';
        sAcct.BillingState = 'NY';
        sAcct.BillingCountry = 'USA';
       	 insert sAcct;
       	
                
        //create contact for Account "Test Account" and create contact address
        Contact[] sContact = new Contact[]{
        	new contact(
        MailingStreet = '1 Initial street',
       	MailingCity = 'Rochester',
        MailingPostalCode = '12456',
        MailingState = 'NY',
        MailingCountry = 'USA',
        accountid = sAcct.id),
                
        	new contact(
        MailingStreet = '2 Initial street',
        MailingCity = 'Rochester',
        MailingPostalCode = '12456',
        MailingState = 'NY',
        MailingCountry = 'USA',
        accountid = sAcct.id),
       
        	new contact(
        MailingStreet = '3 Initial street',
        MailingCity = 'Rochester',
        MailingPostalCode = '12456',
        MailingState = 'NY',
        MailingCountry = 'USA',
                accountid = sAcct.id) };
       
        insert sContact;
        
        //change address on account
        sAcct.BillingStreet = '11 Updated Street'; 
        sAcct.BillingCity = 'Updated City';
        sAcct.BillingPostalCode = '99999';
        sAcct.BillingState = 'PA';
        sAcct.BillingCountry = 'Mexico';
          
        Test.startTest();
         update sAcct;//this should fire my trigger.
        Test.stopTest();
             
               
        sContact = [Select id, accountid, MailingStreet, MailingCity,MailingPostalCode, MailingState, MailingCountry from 
                     contact where id in: sContact];
        
        //check if account updated address match each contact address
       	System.assertEquals(sAcct.BillingStreet, sContact[0].Mailingstreet); 
        System.assertEquals(sAcct.BillingCity, sContact[0].MailingCity); 
        System.assertEquals(sAcct.BillingPostalCode, sContact[0].MailingPostalCode); 
        System.assertEquals(sAcct.BillingState, sContact[0].MailingState);
        System.assertEquals(sAcct.BillingCountry, sContact[0].MailingCountry);
        
        //check addresses didn't match before update
        System.assert(sContact[1].MailingStreet != sAcct.BillingStreet); 
        System.assert(sContact[1].MailingCity != sAcct.BillingCity); 
        System.assert(sContact[1].MailingPostalCode != sAcct.BillingPostalCode); 
        System.assert(sContact[1].MailingState != sAcct.BillingState);
        System.assert(sContact[1].MailingCountry != sAcct.BillingCountry);
        
    }
}

 noobfn

  • August 02, 2013
  • Like
  • 0

I've been staring at the Salesforce bulkify best practice pages for like an hour, and it's just not happening for me. 

 

I have 2 custom objects, Supply and Shipment.  They're related through a lookup field, namely Supplies__c.Shipment__c.  But, my warehouse doesn't have access to the SFID's, so they're recording the "Tracking" numbers instead -- a unique identifier.  At the end of the day, I upload a list of those tracking numbers onto Supplies__c.Tracking__c and built this trigger to update the Supplies__c.Shipment__c  lookup field automatically. 

 

This trigger code queries all the Shipments, finds the one that has the tracking number in question, and updates the Supply record's lookup field with the Shipment__c.id.  Works great!  But, it blows up in bulk because of the query inside the for() loop.

 

Trigger GrabLocationFromShipment on Supplies__c (before insert, before update) {
  for (Supplies__c  s: trigger.new) {
    if(s.Tracking__c != null) {
       List<Shipment__c> ship = new List<Shipment__c>();
ship = [Select Id from Shipment__c WHERE Shipment__c.Tracking__c = :s.Tracking__c LIMIT 1]; if (ship.size() > 0){
s.Shipment__c = ship[0].Id; } } } }

 

How do I run this query outside the for() loop, and still return the matching IDs so I can update the lookup?

  • August 02, 2013
  • Like
  • 0

We're working on our first trigger. I am trying to update a custom field in TASK with a list of Partner accounts related to the account the task is being created for. The code below works if I update a task, but it does not work upon creation of a new task. I tried to execute the trigger after update but received a read only error.

 

Any help is greatly appreciated. We're working on this in the free version of developer force if that matters.

 

trigger JWGetAssociations on Task (before insert, before update) {
    
    Map<Id, Id> TaskToAccountMap = new Map<Id, Id>();
    Map<Id, Id> AcctToPartnerMap = new Map<Id, Id>();
    Map<Id, Account> PartnerResponseMap = new Map<Id, Account>();

    for(Task jwtask : [SELECT Id, AccountID FROM Task WHERE ID in: trigger.new]){
        TaskToAccountMap.put(jwtask.id, jwtask.AccountId);
    }
    
    list <Id> partner1 = new list <Id>();
    for(Partner partner : [SELECT Id, AccountToId, AccountFromId FROM Partner WHERE AccountFromId in: TaskToAccountMap.values()]){
     
        AcctToPartnerMap.put(partner.AccountToId , partner.AccountToId);
    } 

    for(Account part : [SELECT Id, Name FROM Account WHERE ID in: AcctToPartnerMap.values()]){
        PartnerResponseMap.put(part.ID, part);
    }
    
    for(Task o : trigger.new){

        Id acctid = TaskToAccountMap.get(o.Id);

         list <String> partnerAcc = new list <String>(); 
         for( id Accid : AcctToPartnerMap.keyset()){
             Account acc = PartnerResponseMap.get(Accid);
             partnerAcc.add(acc.Name+'\n');
             partnerAcc.add('\n\n');
         }
         for(integer i=0;i<partnerAcc.size();i++){
         }
)
            if(o.jw_Associated_Distributors__c == null){
                o.jw_Associated_Distributors__c = '';
               for(integer i=0;i< partnerAcc.size();i++){
                       o.jw_Associated_Distributors__c += partnerAcc[i];  
                }
        }
    } 
}

 

Hello All,

Once an attachment is inserted I am inserting it to chatter feed(Feeditem) but for some reason the content type is not getting set on feeditem. The attachment has appropriate contenttype that is being used to post to chatter feed. Content type on feed item is not writable so I am not able to set content type explicitly. Any help on this would be greately appreciated. 
REST call to:

/services/apexrest/cms/v1/sample/returnsample/home-page/usa/es

should behave the same as

/services/apexrest/cms/v1/saMple/returNsample/home-page/usa/ESor /services/apexrest/cms/v1/sample/returnsample/hOme-pAGe/uSa/eS

How can we achieve this? Is this possible?
Hello All-

Today when we send email's through salesforce using standard salesforce "Send Email" button on contact along with any attachments there is no way to capture the attachment that has been sent.
I have a requirement where client would like to have a additional check box on send email screen and when checked, the attachment should be saved as an attachment to the contact's attachment related list.

As per my understanding I have to code the complete send email screen using visualforce and I wanted to know if anyone has any ideas around my requirement and if possible any VF code or any link which is similar to standard send email screen for me to start.

Any help on this would be really appreciated.

Thanks!

Hello All-

 

If a contact is in process of updation by some process and at the same time cases associated to the contact are getting updated do we runinto locking issues?

 

As per docs it says that salesforce engine does the following

 

"

  1. First locks sObject parent records, then children.

"

so when a contact is getting updated does salesforce locks its associated cases?

We are using different Article types and when creating article's our users select the visibility like internal app, portals, pkb etc... and for one of the article type users are selecting only pulic knowledge base. In this case when I query, the result set show zero records and If they select both Internal app and Public knowledge base as visibility, then the results show up... 

 

Is there a way to query all the articles only if public knowledge base is selected without selecting Internal App??? Is this an issue or are there any other reasons? 

 

Below is the query I am using... 

 

SELECT Title, Summary
FROM KnowledgeArticleVersion
WHERE PublishStatus='Online'
AND Language = 'en_US'
WITH DATA CATEGORY Cust_Prods__c BELOW All__c

Hello All-

 

We have a situaltion where we expose lots of articles to customers through sites and our business is wanting to have some custom styling process when creating Articles so that all the articles would be consistant from look and feel perspective.. Today they use rich text area for article creation so is there a way where they can select some custom styling during article creation process?

 

Any sample code around Artycle type custom templates with styling would be really helpful...

 

Thanks!

Hello All-

 

We have a situaltion where we expose lots of articles to customers through sites and our business is wanting to have some custom styling process when creating Articles so that all the articles would be consistant from look and feel perspective.. Today they use rich text area for article creation so is there a way where they can select some custom styling during article creation process?

 

Thanks, Sai

We are trying to clone an existing call center with in salesforce and receiving this error...

 

Custom setup limit exceeded

There is a limit of 3,000 custom setup for each application. 

Click here to return to the previous page.

 

Any Idea?? What does this error mean?

 

Thanks.

We are using a visualforce page where we would be presenting leads to our users based on the skill sets on the products that they have knowledge about. User will be presented this page soon after they click on visualforce tab and they will have options like "Retrieve Lead" initially but soon after clicking it the appropriate lead would be presented and the respective hovers are visible. Here they will have few more options like "Release Lead" and "Release and Retrieve Lead" buttons where they can release or release and retrieve a new lead but here hovers are not visible... here is our complete code...

 

<apex:page standardcontroller="Lead" extensions="ICG_LeadOwnershipProcessor" action="{!leadOwnershipFlowController}" cache="true">

<apex:variable var="lead" value="{!currentLeadAssigned}" />
<apex:variable var="assignedActivity" value="{!currentTimerActivity}" />
<apex:form >


<apex:pageBlock title="Lead Manager" tabStyle="Lead" id="sectionPageBlock">
<apex:pageBlockSection columns="2" rendered="{!IF(lead.id!=null&&lead.name!=null,true,false)}" title="Assigned Lead">
<apex:pageBlockSectionItem dataStyle="width:20px;"><apex:outputLabel >Lead</apex:outputLabel>{!lead.Lead_Id__c}</apex:pageBlockSectionItem>
<!--
<apex:inputField value="{!assignedActivity.Call_Outcome__c}" required="true"/>
-->
<apex:pageBlockSectionItem >

<apex:outputLabel >Call Outcome</apex:outputLabel>

<apex:selectList value="{!Outcomes}" size="1"> <!-- required="true" -->
<apex:selectOptions value="{!CallOutcome}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>

</apex:pageBlockSection>
<apex:pageBlockSection columns="3" rendered="{!IF(lead.id!=null&&lead.name==null,true,false)}" title="Released Lead">
<apex:outputField value="{!lead.name}" rendered="{!IF(lead.name==null,false,true)}"/>
<apex:pageBlockSectionItem rendered="{!IF(lead.name==null,false,true)}"><apex:outputLabel >Owner</apex:outputLabel><apex:outputField value="{!lead.owner.name}"/></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem ><apex:outputLabel >Lead</apex:outputLabel><apex:outputLink value="/{!lead.id}">{!lead.id}</apex:outputLink></apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!IF(lead.id==null,true,false)}" title="Assigned Lead">You have no leads assigned to you.</apex:pageBlockSection>
<apex:pageBlockSection title="Messages" columns="1"><apex:messages rendered="true" id="messages"/></apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandLink value="Retrieve New Lead" id="retrieve" action="{!leadOwnershipFlowController}" styleClass="btn" style="padding:2px 5px 2px 5px; text-decoration:none;" rendered="{!IF(lead.name!=null,false,true)}" status="checkStatus" rerender="sectionPageBlock,detailPage,nameValue" onclick="this.disabled=true"><apex:param name="command" value="Retrieve" assignTo="{!command}"/></apex:commandLink>
<apex:commandLink value="Release Lead" action="{!leadOwnershipFlowController}" styleClass="btn" style="padding:2px 5px 2px 5px; text-decoration:none;" rendered="{!IF(lead.name==null,false,true)}" status="checkStatus" rerender="sectionPageBlock,detailPage" onclick="this.disabled=true"><apex:param name="command" value="Release" assignTo="{!command}"/></apex:commandLink>
<apex:commandLink value="Release & Retrieve New Lead" action="{!leadOwnershipFlowController}" styleClass="btn" style="padding:2px 5px 2px 5px; text-decoration:none;" rendered="{!IF(lead.name==null,false,true)}" status="checkStatus" rerender="sectionPageBlock,detailPage,nameValue" onclick="this.disabled=true"><apex:param name="command" value="releaseAndRetrieve" assignTo="{!command}"/></apex:commandLink>
<apex:commandLink value="Convert" action="{!leadOwnershipFlowController}" styleClass="btn" style="padding:2px 5px 2px 5px; text-decoration:none;" rendered="{!IF(lead.name==null,false,true)}" status="checkStatus" rerender="sectionPageBlock" onclick="this.disabled=true"><apex:param name="command" value="convert" assignTo="{!command}"/></apex:commandLink>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:outputPanel id="actionStatus" layout="block" style="text-align:center;font-family:Georgia;font-size:125%;">
<apex:actionStatus layout="block" id="checkStatus" startStyle="background-color:#ddffff;width:150px;height:25px;text-align:center;margin-left:500px;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;vertical-align:middle;"
startText="Processing Request..."
stopText="" />
</apex:outputPanel>
<apex:outputPanel id="detailPage">
<apex:detail subject="{!currentLeadAssigned}" relatedList="true" rendered="{!IF(currentLeadAssigned.id!=null,true,false)}" inlineEdit="true"/>
</apex:outputPanel>
</apex:form>


</apex:page>

Hello-

 

How to make sure that the trigger is fired when a record is created/updated/deleted from UI only.

 

Any suggestions?

 

Thanks, Sam 

// Datetime on July 03, 2012 at 1:06:08 AM in local timezone.

Datetime startTime = Datetime.newInstance(2012, 7, 3, 1, 6, 8);

 

// Datetime on July 5, 2012 at 4:06:08 PM in GMT timezone.


Datetime endTime = Datetime.newInstanceGMT(2012, 7, 5, 16, 6, 8);

 

system.debug('startTime>>> '+startTime+' EndTime>>> '+endTime);

 

Output:
17:34:39.118 (118314000)|SYSTEM_METHOD_ENTRY|[30]|System.debug(ANY)
17:34:39.118 (118323000)|USER_DEBUG|[30]|DEBUG|Start Time>>>2012-07-03 08:06:08    End Time>>2012-07-05 16:06:08

 

DateTime.newInstance is returning datetime in GMT where as DateTime.newInstanceGMT is returning in my local timezone. As per the Documentation newinstance should return datetime in local time zone and newInstanceGMT should return datetime in GMT.

 

Am I missing something here or my usage is incorrect. Please help me understand.

Thanks.

Hello,

 

I have a requirement where I will have to convert a unique 64 character string to a unique 20 character string. 

 

Eg:

Input:abcdef57AgYi8oPidnskd908234ksdjsdjlsdjksd092kj

Output: asdf123asdf123asdf12

 

Everytime i give the same input i should get the same output. We have around 5+ Million records to be updated.

 

Please let me know if you have any ideas around solving the problem.

 

Thanks.

Can we have multiple CTI Adapters running at a same time for a single user? We have a situation where we will need to have two adapters..Avaya and SimpliCTI to be shown up when a user logs into salesforce. One adapter handles Inbound calls and one outbound calls...

 

Please let me know the possibilities.. and issues we may run into if we can.

 

Thanks.

Please help me fix this issue... when I click on the link it is giving me the error. I can use outputlink but here before redirecting it to opportunity page i have to do some operations...

 

visualforce code:

<apex:pageBlockTable value="{!Opptys}" var="Opp">   

  <apex:column headerValue="Opportunity Name">     

       <apex:commandLink value="{!Opp.name}" action="gotoOpp">         

             <apex:param name="getOpp" value="{!Opp.Id}"/>     

       </apex:commandLink>   

      </apex:column>

  <apex:column value="{!Opp.StageName}"/>

  <apex:column value="{!Opp.Product_Category__c}"/>

</apex:pageBlockTable>

 

Controller part:

Public PageReference gotoOpp(){

/*some operations to be accomplished here*/

String oppId = System.currentPageReference().getParameters().get('getOpp');

PageReference pageRef = new PageReference('/'+oppId);

}

 

Appreciate your time.

 

Thanks, Sam

Hello-

 

Is there a way to calculate difference between two date time fields in hours? Can you please point me in the right direction.

 

Appreciate your time.

 

Thanks.

Hello All-

 

What happens when a lead is submitted using web to lead form? Is it a synchronous submission to salesforce or Asynchronous submission? Please provide me links/docs if there are any around this.

 

Thanks for your time.

 

Thanks.

Hello All-

 

Problem: If the string is '(234) 567-8990' then i want the output of the string as '2345678990'. 

 

any help would be appreciated.

 

Thanks.

Hello,

 

Can anyone help me out with this following response..

 

|CALLOUT_RESPONSE|[31]|System.HttpResponse[Status=HTTP Version Not Supported, StatusCode=505]

 

What does it mean?

Hello-

 

we are looking for sms Integration so can you please let me know the available vendors, complexities, approach and any of your experiences would be of great help.

 

Thanks for your time.

Hello All-

 

I am trying to display list of records (Search Results) with radio button selection. We can use wrapper class to display list of records with checkboxes available for each record... Is it possible to have radiobutton in place of checkbox?  Can you please suggest me way to do it.. or any sample code...

 

Thanks.
 

Hello All-

 

I scheduled the following schedulable class and I am getting a strange error...

 

|EXCEPTION_THROWN|[18]|System.StringException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.

 

Code:

 

global class ICG_FixDuplicateLeadsProcessorExtends implements Schedulable{
    
    // global method - execute
    // Call Batch method
    global void execute(SchedulableContext sc) {
        //  Instantiate class
         ICG_FixDuplicateLeadsProcessor FixDuplicateLeadsProcessor = new  ICG_FixDuplicateLeadsProcessor();
        String seconds = '0'; //Execute at Zero Seconds
        String minutes = '30'; //Execute at every 30th minute of hour
        String hours = '*'; // Execute Every Hour
        String dayOfMonth = String.valueOf(Datetime.now().day()); // Execute on current Day of the current Month
        String month = String.valueOf(Datetime.now().month()); //Execute current Month
        String dayOfWeek = '';
        if(Datetime.now().day()>7)
            dayOfWeek = String.valueOf((Datetime.now().day()/7));
        else
            dayOfWeek = String.valueOf(Datetime.now().day());
        String year = String.valueOf(Datetime.now().year()); //Execute only for year 2011

    //Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
        String sch = seconds + ' ' + minutes + ' ' + hours + ' ' + dayOfMonth + ' ' + month + ' ' +dayOfWeek+ ' ' + year;
    //String sch = '0 30 * 5 5 ? 2011';
system.debug('Scheduled time string---->>>>>'+sch);
system.schedule('Fix Duplicate Leads', sch, FixDuplicateLeadsProcessor);
        //database.executebatch(FixDuplicateLeadsProcessor,200);
    }
    
}

 

If I remove the "dayofWeek" from the string sch i get the following error...

EXCEPTION_THROWN|[18]|System.StringException: Day-of-Week values must be between 1 and 7

 

Any thoughts?

 

Thanks

 

Hi all

How to solve this Requirment

i have a custom object having date field and formula field...when i am creating record on custom object i have selected date ans some required fied then click on save for creating record then formula field value automaticallu updated.simillar i have craeted lot up record..how to track datewise formula field....means on particular date what is the formula field value..
Does anyone know if it's possible through declarative logic to update a task based on a field update in the parent (specifically opportunity) record? If not, can this be accompished with a trigger? Thanks for you help!
 

On the Content object page I can see it dispalyed in Kb or other sizes, but when I display the contentsize field on a Visualforce page it shows the size in bytes.  I would like it to appear as Kb, Mb, or Gb.  A contractor had used some JavaScript to calcuate the size on another page, but I'd rather not use JavaScript as I'd like to try and stay server side instead of client side.  What are my options?  Do I use forumula on a second hidden field, is there some Visualforce tag I can use? 

Trying to write a Test Utility so I can call it in various test methods.  I've got this so far but getting an error
Constructors cannot be static at line 4 column 19

can anyone tell me what I'm doing wrong please?
@isTest
public class CW_DataCreation{

    public static CW_userDataCreation(){
     //create Tier 2 user
        Profile p = [SELECT Id FROM Profile WHERE Name='CW Software Support - Tier 2' limit 1]; 
        UserRole r = new UserRole(Name='CW Tier 2');
        User u1 = new User(LastName = 'Test Class',
                                    Username = 'TestClass@Test.com',
                                    UserRole = r,
                                    Profile = p,
                                    Email = 'Tier2Test@Test.com',
                                    Alias = 'tclass',
                                    CommunityNickname = 'tclass',
                                    TimeZoneSidKey = 'Asia/Kolkata',
                                    LocaleSidKey = 'en_US',
                                    EmailEncodingKey = 'UTF-8', 
                                    ProfileId = p.Id,
                                    LanguageLocaleKey = 'en_US',
                                    License_Owner__c = 'CW');
        insert u1;
        }
        return u1;
        }

 
  • February 19, 2015
  • Like
  • 0
what happen when you import data using data loader if reparent option is checked and non checked?
The below button works great on the full site but on Salesforce1 it throws a bad URL error.  See button setup below.  Any help/guidance is much appreciated.

Button setup

Apex Trigger to Populate Custom Field of type Lookup in Opportunity Object with Account Owner from Account Object,how can i achieve this
Hi All,

I need to create a PDF and attach to the case when case is not updated for 10 days. Is there any way to achieve this without using triggers?

I can not use trigger because my PDF will contain images and the methods Blob.toPdf() and getContentAsPdf() are not supported by triggers if PDF contains image. Hence I need to do something similar to field updates and then invoke apex class without using trigger

Can somebody please suggest how can I invoke apex class or VF page based on filed update?

Thanks. Have a nice day!
Hi,

I have an aggregate result query that is working, but I need to add another paramenter so I can get the query AND the Id of the Account I'm querying.  But I can't figure out how to do it.  If I add the Id field I get an error.

Thanks,
 
public List<AcctSumList> getAccountSummary60() {
        list<AcctSumList> acctSummary = new List<AcctSumList>();
        List<AggregateResult> getList = [SELECT Account.Name acctName, sum(amount) TotalAmount 
                                         FROM Opportunity 
                                 		 WHERE (Account.OwnerId =: UserId OR
                                         Account.Client_Specialist_1__c =:UserId OR
                                         Account.Client_Specialist_2__c =:UserId OR
                                         Account.Client_Executive__c =:UserId) 
                                         AND StageName='B. Decision Due' AND CloseDate = THIS_Quarter
                                         GROUP BY Account.Name ORDER BY sum(amount) DESC LIMIT 10];
        for(AggregateResult agg : getList) {
            String AccountName = (string)agg.get('acctName');
             Double TotalAmount = (double)agg.get('TotalAmount');
            acctSummary.add(new AcctSumList(AccountName, TotalAmount));
        }
        return acctSummary;
    }

 
I was hoping to use a visualforce page to display a banner type message at the top of account records, what I have is below:

<apex:page standardController="Account" sidebar="false" showHeader="false" showChat="false"> <apex:pageMessage summary="Testing" severity="warning" strength="3" rendered="{!Account.custom_field_c <> NULL}" /> </apex:page>

But instead of displaying "Testing" I want it to display the text in the custom_field_c. Is that possible?

Thanks for any help! I haven't done anything with apex or visualforce before.
 
  • February 17, 2015
  • Like
  • 0
i am trying to update a field on Lead object based on activity. Here is the code. When i create an acitvity on leads this field remain blank. Am i missing something. 
trigger UpdateLeadCounts on Task (after delete, after insert, after undelete, after update) {

set<ID> LeadIds= new Set<ID>();
for(Task tt:trigger.new)
{
if(tt.whoId!=null && string.valueof(tt.WhoId).startsWith('003'))
{

LeadIDs.add(tt.whoID);
}
}

if(LeadIds.isEmpty())
return;
List<Lead> cnts= new List<Lead>();

Integer number1=1;
for(Lead ct:[select id, name, count1__c from Lead where id in:Leadids])
{

if(ct.count1__c ==null)
ct.count1__c=0;

ct.count1__c=ct.count1__c+number1;


cnts.add(ct);
}

if(cnts.size()>0)
{
update cnts;
}
}
 
Hi,

I am very much a newbie, so apologies if this is an extremely basic question.  I've put it in Apex Code Development because I suspect that the answer lies there but please feel free to move it if required.

We have set up a Contract process to manage our marketing expenditures and, following final approval, the contract owner should send an email, using a pre-determined template, to their contact to confirm the particulars of the contract.  Unfortunately, the contract owner COULD send the confirmation at any time (but we have told them not to do so).  Once final approval has been achieved, the contract status is set to "Terms Sheet Needed".

How do I:

(a) Ensure that it is impossible the email template ("MDF International Contract") until the status is set to "Terms Sheet Needed"
(b) Set the status automatically to "Fully Executed" once the email template has been successfully sent.

All help gratefully accepted!
 
On the Orders I have a custom field called Suppliers(picklist field). We create an order from the customer's account (order related list), and we select the supplier via a drop down field. My question is when on the activity history press send an email on the ''To'' I need to fill in the contact name again. Is there a way that area could be field automatically from the custom field that I have already insert the supplier?
My company owns an Enterprise Edition if this help you all.

Thank you in advance

User-added image
Hi,
I am trying to create a query that shows me all the contact owner and account owner are different.

Here is what I have now:
 
Select Id, AccountId, OwnerID, Acccount.OwnerId 
    FROM Contact 
    WHERE OwnerId != Account.OwnerID


Here is the error i am receving in Query Editor:
Unknown error parsing query

I am assuming this is because one of them is polymorphic and can be user or queue.  Any thoughts are a work around for this query?

 
I am trying to implement a roll-up summary of the earliest contract start date on the account object using the code outlined here (http://blog.elieperez.net/salesforce-lookup-roll-up-summary/). Below is my trigger.
 
trigger rollupContractsOnAccount on Contract (after insert,after update,after delete,after undelete) {
     
    string mysobjectParent = 'Account',      // Parent sobject API Name
           myrelationName = 'Contract__r', // Api name of the relation between parent and child (ends with __r)
           myformulaParent = 'Customer_Since__c',        // Api name of the number field that will contain the calculation
           mysobjectChild = 'Contract',  // Child sobject API Name
           myparentfield = 'Account', // Api name of the lookup field on chield object
           myfieldChild = 'Subscription_Start_Date__c';          // Api name of the child field to roll up
     
    LookupCalculation.Method method = LookupCalculation.Method.MIN; //Selected method: could be COUNT, SUM, MIN, MAX, AVG
     
    LookupCalculation calculation = new LookupCalculation(mysobjectParent, myrelationName, myformulaParent,
                                                          mysobjectChild, myparentfield, myfieldChild);
    List<sobject> objList = new List<sobject>((List<sobject>) Trigger.new);
    if(Trigger.isDelete)
        objList = Trigger.old;
    if(Trigger.isUpdate)
        objList.addAll((List<sobject>) Trigger.old);
    calculation.calculate(method, objList);
}

This gives me the error:

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger rollupContractsOnAccount caused an unexpected exception, contact your administrator: rollupContractsOnAccount: execution of AfterInsert caused by: System.SObjectException: Invalid field Account for Contract: Class.LookupCalculation.Calculate: line 25, column 1

What am I missing? The error is on "myparentfield," which is correct as Account for the Contract object.
  • January 28, 2015
  • Like
  • 0

Hello, I'm quite new to the bulkifying idea and need to bulkify the following sinmple trigger, which just updates a field on a parent object:

 

trigger Approval_Actions on Approval__c (after update) {
    List<Approval__c> app = trigger.new;
    Opportunity opp = [select Approval_Date__c from Opportunity where Id =: app[0].Opportunity__c LIMIT 1];
    if(app[0].Status__c == 'Approval GRANTED'){
       opp.Approval_Date__c = date.today();
    }
    update opp;
}

 

The problem is: how to bulkify it without having an SQL query in a loop?

In a test class, I am trying to create an opportunity of a specified record type. 

 

   //create opportunity record
        String opportunityName= 'xxxx';
            Opportunity o = new Opportunity(
            AccountId=a.Id, 
            Name=opportunityName, 
            StageName='Prospecting', 
            CloseDate=Date.today(),
            Opportunity_Type__c='New',
            LeadSource='xxx',
            RecordTypeId= [Select Id From RecordType Where Name = 'xxx' and SobjectType= 'Opportunity'].Id);
            
        insert o;
        system.debug(o.RecordType.Name);
        

 

However this returns- null in the debug statement. I'm sure i'm overlooking something simple. Any help?

  • December 03, 2013
  • Like
  • 0

hi friends

i got this requirement.

please help

In Account object i created one custom field called " COUNT" so the question is ,whenever i created a contact related to that account ,COUNT custom field has to show the number,how many contacts has been created so far....

one important thing is ,pls consider all events in trigger...like before insert,after update and delete also come into the existence...

how do i write trigger for this..

Thanks