• Pavan Dave
  • NEWBIE
  • 80 Points
  • Member since 2014

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 42
    Replies
Hi All,
We created a trigger for Chatter. When a post contains keyword ”legal', a new record under ChatterPost will be generated. We also created Test class but got error, please help, thank you so much.

Compile Error: Illegal assignment from Schema.SObjectField to Id at line 8 column 9

@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem post = new FeedItem();
        post.ParentId = ChatterPost__c.Id;
        post.Body = 'legal test';
        insert post;
        Test.StopTest();
        System.assertEquals ('legal test', post.body);
    }
}

TRIGGER:
Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body!=null &&   f.body.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hello,

I created the trigger below to fire when a custom object is created to create a clone of the Opportunity related to the custom object.  I added a system.debug line on line 19, and it shows that the variable "amh2.Opportunity__r.Managed_Account_Transfer__c" is set to FALSE.  However, this checkbox field on the Opportunity is set to TRUE.  Does anyone know how to fix this?  Thanks.

public class ClassAccountManagerHandoffNotes {
    
    public void autoCreateRenewal1(Account_Manager_Handoff__c[] newAMH){

        Map<String,String> oppMap = new Map<String,String>();
        Set<Id> parentOpp = new Set<Id>();
    

        FOR (Account_Manager_Handoff__c amh1 : newAMH) {
            parentOpp.add(amh1.Opportunity__c);

        Map<Id,Opportunity> oppMap2 = new Map<Id,Opportunity> ([SELECT Id
                                                                FROM Opportunity
                                                                WHERE Id IN :parentOpp]);
                                                                
        FOR(Account_Manager_Handoff__c amh2 : newAMH){ 
        

        system.debug('********AMH'+amh2.Assigned_Account_Manager__c+' '+amh2.Opportunity__r.Managed_Transfer__c);
        IF(oppMap2.containskey(amh2.Opportunity__c) && amh2.Assigned_Account_Manager__c != NULL && amh2.Opportunity__r.Managed_Transfer__c == TRUE){
  
            Opportunity renewalOpp = amh2.Opportunity__r.clone(false);

                Opportunity clonedObj = renewalOpp.clone(false,true);
                          
                clonedObj.Name = amh2.Opportunity__r.Acct_Name__c + ' - Renewal (' +amh2.Opportunity__r.Renewal_Date_Year__c + ')';
                clonedObj.OwnerId = amh2.Assigned_Account_Manager__r.Id;
                clonedObj.StageName   = 'Active Discussions';
                clonedObj.CloseDate   = amh2.Opportunity__r.Renewal_Date_Next__c;
                clonedObj.Amount = amh2.Opportunity__r.Amount;
                clonedObj.Effective_Date__c  = amh2.Opportunity__r.Renewal_Date_Next__c;
                clonedObj.Renewal__c = 'Yes';
                clonedObj.Renewed_Opportunity__c = amh2.Opportunity__r.Id;
                clonedObj.Probability = 5;
    
    insert clonedObj;
        }
    }
}
}
}


When records are created in offline mode of mobile and those records are synced with salesforce by webservices when device is online . On response its creating duplicate records in mobile data . Smartstore is used for data storage and soup methods for all DML operations .
I need to update custom picklist values ( for custom field on Product2 ) from PHP(Website) to Salesforce

I can update data (i.e. records)

but is their a way to update THE VALUES IN THE PICKLIST ITSELF FROM the website, as I have the connection establish ann I can access SDFC from my website.

Thanks in advance
Sunny
HI Folks,

I have a scenario i.e, Whoever is created the record but that record users manager & system admin only edit the record based on Grade field. For this i implemented a validation, but its not working properly. So please suggest me.

AND(
OR(ISCHANGED( Grade_1__c ), ISCHANGED( Grade_2__c ), ISCHANGED( Grade_3__c )),
OR( $User.Id=$User.ManagerId )
)

Highly appreciated!!

I have difficulty in getting the case comments to the body of the email when invoked through javascript through a button. I have a custom button called Send Email and when clicked on Send Email, it opens the email client (In my case outlook). The To, CC, Subject are all filled through field reference in the javascript but i am not able to fill the body of the email with the last case comment that is public.
The javascript (Onclick Javascript under custom button) i have is as below

javascript:location.href='mailto:{!Contact.Email};{!Case.Additional_To_Emails__c}?CC=support@aryaka.com&SUBJECT=[{!Case.CaseNumber}] [{!Case.Subject}][{!Case.Ref_ID__c}] &BODY={!Case.Last_Case_Comment}';

{!Case.Last_Case_Comment} is not getting filled in the body of the email. Any suggestions to make it work?

Regards
Deepak
Hi All,
We created a trigger for Chatter. When a post contains keyword ”legal', a new record under ChatterPost will be generated. We also created Test class but got error, please help, thank you so much.

Compile Error: Illegal assignment from Schema.SObjectField to Id at line 8 column 9

@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem post = new FeedItem();
        post.ParentId = ChatterPost__c.Id;
        post.Body = 'legal test';
        insert post;
        Test.StopTest();
        System.assertEquals ('legal test', post.body);
    }
}

TRIGGER:
Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body!=null &&   f.body.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hey everyone,

I have a task trigger that depends entirely upon the value in the WhoID field upon creation. I noticed that if a task is created via a BCC'd email, the trigger doesn't work. After putting in some debug statements, I saw that WhoID isn't populated upon creation when the task if from a BCC'd email.

Any idea what I should do?

Thanks,
Greg
I believe I've ran into a limitation in SF, in that I cannot create a roll up summary on a cross object formula field.  Here's my scenario:

We have a custom Object: TimeSlip__c, which contains a field "Billable_Amount__c" that is a cross object formula.  It take the "Rate__c" from another related object (Case_Resource__c) and multiplies it by the number of hours entered on the TimeSlip (Total_Billable_Time__c).  

I'm trying to create a rollup summary on the Case Page that calculates the toal Billable Amount from all timeslips by rolling up the "Billable_Amount__c" field, but SalesForce isn't giving me this option.

I've been told I can achieve this with a trigger, and need some help writing the Apex Code.
  • September 17, 2014
  • Like
  • 0
Hi All,
We created a trigger on Chatter. If a post mentions “legal" keyword, a new record under ChatterPost object is created automatically. But it's not working, no new record is created, please help.

Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body == '!legal' ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hi,

Has anyone tried to pull data, such as user information, out of Salesforce and into Wordpress.  Wanting to be able to present Salesforce informatino on big screen TV's within a company.  They now use Wordpress to put up other information.

Anyone know of a way to do this.  Would like to also be able to put up Idea's in this manner.  Show the top 5 or 10.  

Thanks!
I need to update custom picklist values from PHP(Website) to Salesforce  I can update data (i.e. records)  but is their a way to update THE VALUES IN THE PICKLIST ITSELF FROM the website, as I have the connection establish ann I can access SDFC from m
I am in the learning stages of Salesforce Apex. I have read the topic of Dynamic Apex but not able to understand the concept, Can someone explain it how to deal with it and in which scenarios it is best to use?

Thanks in advance!!
  • September 17, 2014
  • Like
  • 0
Hello,

My trigger below is designed to clone an Opportunity related to a custom object record (Account_Manager_Handoff__c).  An Opportunity record is being created whe I specify field values, however, fields from the related Opportunity that it is meant to clone are not coming through unless the manadatory values are included in the trigger code.  My expectation was that Line 29 of my trigger would clone all the values in the related Opportunity, except any that I specified otherwise.  Can anyone help as to why this is ot happeing?  Thanks,

/public class ClassAccountManagerHandoffNotes {


    public void autoCreateRenewal1(Account_Manager_Handoff__c[] newAMH){

        Map<String,String> oppMap = new Map<String,String>();
        Set<Id> parentOpp = new Set<Id>();
    

        FOR (Account_Manager_Handoff__c amh1 : newAMH) {
            parentOpp.add(amh1.Opportunity__c);

        Map<Id,Opportunity> oppMap2 = new Map<Id,Opportunity> ([SELECT Id
                                                                FROM Opportunity
                                                                WHERE Id IN :parentOpp]);
                                                                

        set<Id> amhIds = trigger.newMap.keyset();
        List<Account_Manager_Handoff__c> amhOppData = [SELECT Opportunity__r.Managed_Transfer__c, Opportunity__c,Opportunity__r.Primary_Contact__c,Assigned_Account_Manager__c,Opportunity__r.Acct_Name__c,Opportunity__r.Renewal_Date_Year__c,Assigned_Account_Manager__r.Id,Opportunity__r.Renewal_Date_Next__c,Opportunity__r.Amount,Opportunity__r.Id,Opportunity__r.Business_Goals__c
                                                        FROM Account_Manager_Handoff__c
                                                        WHERE Id IN :amhIds] ;
       FOR(Account_Manager_Handoff__c amh2 : amhOppData){ 
        

        system.debug('********AMH'+amh2.Assigned_Account_Manager__c+' - Acct Manager '+amh2.Opportunity__r.Managed_Transfer__c);
        IF(oppMap2.containskey(amh2.Opportunity__c) && amh2.Assigned_Account_Manager__c != NULL && amh2.Opportunity__r.Managed_Transfer__c == TRUE){
        system.debug('********AMH  Opportunity: '+amh2.Opportunity__c+' Assigned AM: '+amh2.Assigned_Account_Manager__c+' Mgd Transfer: '+amh2.Opportunity__r.Managed_Transfer__c);
  
            Opportunity renewalOpp = amh2.Opportunity__r.clone(false,true);

 //               Opportunity clonedObj = renewalOpp.clone(false,true);
                          
/*                renewalOpp.Name = amh2.Opportunity__r.Acct_Name__c + ' - Renewal (' +amh2.Opportunity__r.Renewal_Date_Year__c + ')';
                renewalOpp.OwnerId = amh2.Assigned_Account_Manager__r.Id;
                renewalOpp.StageName   = 'Active Discussions';
                renewalOpp.CloseDate   = amh2.Opportunity__r.Renewal_Date_Next__c;
                renewalOpp.Amount = amh2.Opportunity__r.Amount;
                renewalOpp.Effective_Date__c  = amh2.Opportunity__r.Renewal_Date_Next__c;
                renewalOpp.Renewal__c = 'Yes';
                renewalOpp.Business_Goals__c = amh2.Opportunity__r.Business_Goals__c;
                renewalOpp.Primary_Contact__c = amh2.Opportunity__r.Primary_Contact__c;
                renewalOpp.Renewed_Opportunity__c = amh2.Opportunity__r.Id;
                renewalOpp.Probability = 5;*/
    
    insert renewalOpp;
    system.debug('@@@@@@@@' + renewalOpp);
    }
    }
    }
    }
  

}


Hi all!  I configured Live Agent and have the development code and chat button code but am stuck on site.  Have tried adding both to header.php and footer.php but no success.  Any tips?  Thanks!