• pooja chauchan
  • NEWBIE
  • 320 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 32
    Questions
  • 5
    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.

Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ParentId]: [ParentId]
Stack Trace Class.ChatterPostTest.insertNewChatterPostTest: line 9, column 1


@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem f = new FeedItem();
        f.Body = 'legal test';
        insert f;
        Test.StopTest();
        System.assertEquals ('legal test', f.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;
        }
    }
   }
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!!
Hi,

string namevf=name;

            For(Contact objContact:[SELECT  :namevf,id,MailingStreet,MailingCity,MailingCountry,MailingState FROM Contact])
            {
          
          //some code
            
            }

in the above code , I want to replace  ":namevf" with "name"(or any other API name) if I store the API name in another string variable ...
can any one help me on this......
In the code snippet below I am able to see the Contact ID in the variable advisorIDS.  What would I add to the code to see another field on the contact record?
Thanks in Advance

public void doAutoSubscribe(Map<Id, Contact> contactMap) {
    
        Set<ID> advisorIDs = contactMap.keySet();
        system.debug(' ADVISOR ID----- >' + advisorIds);       

}
Hello everyone,

I am trying to do some data manipulation over records in a list. I was able to correctly build my list but now I am stuck with the calculations that I want to see happen.

Let's say I have record 1 and record 2 in my list. I want to grab a field called meter readings on both record and subtract the value of record 2 from the value from record 1 to get the actual energy use.

record 1 energy use = record 1 meter reading - record 2 meter reading.

And obvisouly I would like to repeat that for every records in my list except for the last one (since I would not have a second meter reading to do the calculation).

At first I thought of using a variable to control the for loop but I keep getting the following error message: "System.ListException: List index out of bounds: 15" 
I have a url field that is populated by a third party integration.  This field uses http: to populate the url link.  I would like to convert the http: portion of the url to https: maintaining the remaining url information.  Can this be done?
1) Create some Sort of schedule in Salesforce?
2)  read chunk of data and insert/update?
Hi,

I have used below code to hide the related list.
//This code finds our "Notes and Attachments" related list, and hides it completely:
      var el = document.getElementsByTagName('*');
      for(var i=0;i<el.length;i++){
        if(el[i].id.match('_RelatedNoteList')){ //This finds our related list.
                          //Salesforce appends the record Id to the html name,
                          //so this finds a match disregarding the record Id.
          //We need to toggle both visibility and display for support across various browser types
          el[i].style.visibility="hidden";    //hide visibility
          el[i].style.display="none"; //hide display.
        }
      }


But, i am not able to get ID's or Class name's from right side pane to left nav. pane..
i have created Visualforce page in left nav from homepage component.

please tell me the alternative way to get ID 's from right pane to left pane...

Thank you in advance!!
The field I am trying to include is a text field that contains numbers separated by commas (it was originally a text formula and I created a WFR and Field Update to move it to a text field and am referencing the text field - I did this as a troubleshooting step; the formula and the text field both have the same problem on the VF page).  Both the formula and the text field display fine on the record detail page.  I am displaying lots of other fields on this VF page without issue.  I've tried wrapping the field in HTMLENCODE, JSINHTMLENCODE, nothing.
Error Message: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow
- Where do I upload the website assets so I can call them in my visualforce pages?
- How would I use our login page to align with Salesforce's login credentials as a Community User?
- How do I implement a dynamic "leaderboard" from a custom object?
I have a trigger which creates a new record in the same object based on some criteria. I'm using standard object tab. The requirement is, as soon as user click on save for existing record, and a new record is created by trigger, user should be redirected to the new record in edit mode
Private void UpdatePriceListDate(List<Account> newAccounts){
        //Create the instance for the Account
        List<Account> ChildRecords = new List<Account>();
        //Variable Declaration
        string CurrentAccountNotes;
        string CurrentParentId;
        date PrilistCorrectdate;
       
        for (Account currentrecord : newAccounts) {
            //Getting the parentid, PriceListDate and Account notes
            CurrentParentId = currentrecord.id;
            PrilistCorrectdate = currentrecord.Price_List_Correct__c;
            CurrentAccountNotes =currentrecord.Account_Notes__c;
           
        }
      
        ChildRecords = [Select id,Parentid,Price_List_Correct__c,Account_Notes__c, from account where parentid = :CurrentParentId];
      
        for (Account childrecord : ChildRecords) {
            //Update the PriceList Date to Childrecord
            childrecord.Price_List_Correct__c = PrilistCorrectdate;
            //Update the Account Notes to Childrecord
            childrecord.Account_Notes__c = CurrentAccountNotes;
          
        }
        //Updata the Child Records
        update ChildRecords;
    }
}
I want to write a trigger on the task which updates the task status to completed after the oipportunity is set to Closed Won or Closed lost.

This is to basically prevent any closed opportunities which still have open tasks.
I recently started to research about Sales Force, I was trying to use Sales Force and Postman (REST Service) and I wondered about if is possible to create it using the trial version, because when go to create a class in the "develop" tab I cant see the Apex Class option, is there any other way to create a webservice? Apigee works exacly the same? just creating one service by my own?
trigger CW_Update_Substatus_based_on_Case_Owner on Case (before update)
{
    for (Case objCase : Trigger.new)
    {
        if (objCase.Owner.Profile.Name == 'CW Dealer Portal User')               
        {
            objCase.Substatus__c = 'Open with Dealer';
        }else{
            if (objCase.Owner.Profile.Name == 'CW MineStar Support - Tier 2')               
            {
            objCase.Substatus__c = 'Open with Support Advocates';
            }
            else
                {
                objCase.Substatus__c = 'Open with Product Specialists';
                }
    }        }
}
Hello,

I wanted to know about compatibily of VF with HTML5, I dont know how possible is to mix html5 tabs and Apex Tabs?
I have a trigger that is supposed to change our Substatus depending on the Case Owner(profile or queue name)

right now it will only work if I choose a Queue or Partner user.  If I try to click Change next to Case Owner and assign the Case to a User it gives me the following error:
Error: Apex trigger CW_Update_Substatus_based_on_Case_Owner caused an unexpected exception, contact your administrator: CW_Update_Substatus_based_on_Case_Owner: execution of BeforeUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.CW_Update_Substatus_based_on_Case_Owner: line 10, column 1

I've made this trigger as simple as possible and created 2 formula fields, one to show the queue name if the case is assigned to a queue(CW_Queue_Case_Owner__c) and one to show the profile ID if the case is assigned to a user(CW_Owner_Profile__c).  I have no idea what else could possibly be wrong.  Please help!




trigger CW_Update_Substatus_based_on_Case_Owner on Case (before update, after update)
{
        //Set<Id> ownerIds = new Set<Id>();
        for(Case objCase : Trigger.new){
                //ownerIds.add(objCase.OwnerId);
        }
  
        for (Case objCase : Trigger.new)
        {
           if(objCase.CW_Owner_Profile__c == '00e30000001aw4D'||objCase.CW_Queue_Case_Owner__c.contains('Dealer'))             
           {
                objCase.Substatus__c = 'Open with Dealer';
            }else{
                if((objCase.CW_Owner_Profile__c =='00e30000001c54i' || objCase.CW_Owner_Profile__c =='00ea0000001ds8w') || objCase.CW_Queue_Case_Owner__c.contains('T2'))              
                {
                objCase.Substatus__c = 'Open with Support Advocates';
                }else{
                    objCase.OwnerId = '00G30000001oUSL';
                    objCase.Substatus__c = 'Open with Product Specialists';
                    }
        }       
     }
}
I need to have a user assigned in order to make this test class actually function. My actual class and trigger work as designed, but the test class fails because it requires a user to be present in order to work. Here is the code I have. I'm very new to apex and coding all together so I'm kinda stuck.

@isTest
public with sharing class UpdateNCMOwnerHandlerTest
{
public static testMethod void testUpdateNCMOwnerHandler()
{
  List<Non_Conforming_Material__c> nonConformingMaterials = new List<Non_Conforming_Material__c>();
Non_Conforming_Material__c nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'In Process'); //#1
  nonConformingMaterials.add(nonConformingMaterial);
  nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'Resolution'); //#2
  nonConformingMaterials.add(nonConformingMaterial);
  insert nonConformingMaterials;
    }
}
for (task ta : trigger.new){
        id Opportunityid = ta.WhatId;
      
        Opportunity oOpportunity = [select id, Latest_Open_Due_Date__c from Opportunity where id = :Opportunityid LIMIT 1];
        if (oOpportunity.Latest_Open_Due_Date__c <  ta.ActivityDate ) {
                if (ta.Status != 'Completed' ) {
                        System.debug ('in completed');
                        oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
                //update oOpportunity;
                }
        }
      
        if (oOpportunity.Latest_Open_Due_Date__c == null) {
                if (ta.Status != 'Completed'  ) {
                        oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
                //update oOpportunity;
                }
        }
      
       List <Task> ActiveTask = [select id, WhatId from Task where Whatid = :Opportunityid and status != 'Completed'];
        
                if (ActiveTask.isEmpty()){
                        oOpportunity.Latest_Open_Due_Date__c = null;
                ///update oOpportunity;
                }
        update oOpportunity;
    }