• David Piperato
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am posting this in Java development because I saw a post (referenced below) on stack exchange that suggested I could achieve the desired results with a bit of Javascript. I apologize if this is not that correct place for this question. 

We have added the Salesforce Embedded Service Chat Deployment to one of our websites. The majority of the traffic to this site is coming from Google Ads paid search. If a user chats with us, I'd like to be able to attach the full URL string to the lead, so if the chat results in a conversion I can pass the GCLID back into Google Ads for smart bidding optimization. Salesforce supported pointed us to this article, but the script didn't work for us (perhaps we implemented it incorrectly?): Capture URL of webpage containing Live Agent chat button Can anybody help? To clarify, the URL with all the necessary parameters that I want to capture would look something like this: https://ourdomain.com/landing-page/?b1&utm_source=gaw&utm_medium=cpc&campid=11538955864&adgid=111969187389&kwd=%2Bkeyword&mt=b&s&dev=m&dm=&nw=g&crid=476869308431&gclid=Cj0KCQiA-aGCBhCwARIsAHDl5x9cVnQmdj3yw7lEqUewRWyXCcjx5Hw1NJEGiRjeeq6FEjZW4JNhxE4aAnOjEALw_wcB
I have created a date/time field that I would like to be updated to the date/time any time a note is created on an opportunity. I have no experience with Apex Triggers, so I wanted to use process builder, but it doesn't allow processes to be created for the notes object. After reading a few similar posts, I wrote the following trigger, but it doesn't seem to work. If anybody can explain why and how to fix it, I would greatly appreciate it. Thank you in advance. Trigger:

trigger SetOppDate on Note (after insert) {

List<Opportunity> oppsToUpdate = new List<Opportunity>();
    for (Note nRecord : trigger.new) {
        //Check if the note is related to an opportunity
        String parentIdString = String.valueof(nRecord.parentid);
        if (parentIdString.substring(0,3) == '006'){
            //Set the Last_Note__c field on the opportunity
            Opportunity opp = new Opportunity(Id = nRecord.ParentId, Last_Note__c= Date.TODAY());
            oppsToUpdate.add(opp);
       }
    }
    update oppsToUpdate;

}
I have created a date/time field that I would like to be updated to the date/time any time a note is created on an opportunity. I have no experience with Apex Triggers, so I wanted to use process builder, but it doesn't allow processes to be created for the notes object. After reading a few similar posts, I wrote the following trigger, but it doesn't seem to work. If anybody can explain why and how to fix it, I would greatly appreciate it. Thank you in advance. Trigger:

trigger SetOppDate on Note (after insert) {

List<Opportunity> oppsToUpdate = new List<Opportunity>();
    for (Note nRecord : trigger.new) {
        //Check if the note is related to an opportunity
        String parentIdString = String.valueof(nRecord.parentid);
        if (parentIdString.substring(0,3) == '006'){
            //Set the Last_Note__c field on the opportunity
            Opportunity opp = new Opportunity(Id = nRecord.ParentId, Last_Note__c= Date.TODAY());
            oppsToUpdate.add(opp);
       }
    }
    update oppsToUpdate;

}