• Michael M
  • NEWBIE
  • 280 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 39
    Questions
  • 81
    Replies
Hello, our Contact object has a lookup to our Lead object. When a Lead is inserted or updated, and certain custom fields are not null, a trigger automatically creates a Contact record. One of those custom Lead fields is a rich text area, because after the Contact is inserted, we want to turn that into a hyperlink which can be clicked on to go straight to the Contact record. What would you advise as the best way to do this? Any help in building the trigger would be greatly appreciated. 
Hello, we have a trigger on Lead that creates a Contact based on 2 fields from the Lead . After the Contact is inserted, we want to turn the Lead field that contains the name of the Contact to turn into a hyperlink with a link to that Contact record. I built a trigger, but it is not working, and I am not sure why not. Can someone please help. Here is the trigger:

trigger ContactsTrigger on Contact (after insert) {
     // add mobilephone to set and assign id variable
    Set<String> contactNumSet = new Set<String>();
    Id newConId;
    for (contact c : trigger.new){
        if (c.mobilephone != null){
            newConId = c.id;
            contactNumSet.add(c.mobilephone);
        }
    }
 //query related lead   
 List<Lead> refsToInvestigate = new List<Lead>();       
 List<Lead> refsToUpdate = new List<Lead>();  
 String nok1;
    refsToInvestigate = [select emergency_contact_phone__c from Lead where emergency_contact_phone__c = :contactNumSet];    
        for (Lead ref : refsToInvestigate){
                nok1 = ref.NextofKin__c; }
    
    for (Lead refer : refsToInvestigate){
                refer.nextofkin__c =  '<a href=https://centers--partial.lightning.force.com/'+newConId+'>'+nok1+ '</a>' ;
        refsToUpdate.add(refer);  } 
         update refsToUpdate;

}
Hello, on one of our custom objects, we have a custom external id field. We want to change the format of the field, so we need to either query the records with workbench and then re-import them, or build a report and add a column then import that. The current format for the external id field is name + Date of Birth. So the only thing that all of the records that we want to update have in commin is that the 3rd to last charachter is "-". (E.g. 'Tom Jones1999-09-09'). How can I write a query to fetch all records where the 3rd to last character is a "-"? 
Hello, I need some help assigning the owner of Contact records because of the way in which I am creating these records in the first place. We have an integration built which automatically creates Leads. Now, we have a Trigger (on Lead) that picks up information in some custom Lead fields, and based on those creates new Contact records. 

I want the owner of the Contact record to ALWAYS be the same as the owner of the Lead record. The reason this is complicated is because immediately when Leads are generated by our integration, they are at first (in the first milisecond) owned by the person's account who built the integration. Then, we have a Lead Process Builder that changes the Lead owner based on certain criteria. However, since  in our scenario, the Contact records are being generated from a Lead trigger (which comes before Process Builder in the order of execution), the owner of the Contact keeps being assigned to the ORIGINAL lead owner (the account of the integration builders.) I tried using Contact Process Builder to assign the owner of the contact based on the parent Lead's owner, but that doesn't seem to be working.  What would you advise? 
This may be a basic question, but I need to manipulate a string. I have a string that is a phone number in this format: +18888888888. I need it to become 888-888-8888. How can I do so?
Thank you!
Hello, I have a process builder set up that posts a chatter notification to the Owner of the Lead when a certain custom field gets updated. How can I @mention that user in the body of the chatter post FROM process builder? The reason I need to do so is because I want the user to receive an alert (both a bell on the chatter and an email) when this chatter post gets posted?  FYI the person is always the User-Owner of the Lead record. Your help is greatly appreciated. 
Hello, I have a trigger that updates a Lead field checkbox (to true.) When that checkbox is checked off, I need to send a chatter notification to the owner of that record. What is the best way to do that? Can it be done with workflow rules? I'm afraid if I use process builder, it will fire off several times, because my Lead process is set to fire whenever a record is updated, which I think can sometimes fire more than once even if a field is only update once (unless there's a way to prevent that?) Can it be done in the trgiger itself? What would you recomend?
Hello, Would someone be able to assist in writing a test class for the following apex class:
global class purgeFiles implements Schedulable{
    
    global void execute(SchedulableContext SC) {
        
    List<ContentDocumentLink > docs;
        docs = [SELECT Id, Linkedentity.name, Linkedentity.id,ContentDocument.CreatedDate  
                FROM contentDocumentLink 
                WHERE Linkedentityid 
                IN (SELECT Id FROM lead where createddate < Last_N_Days:7 and isconverted = false) ];  
                //may want to change to include ALL leads
                //AND ContentDocument.CreatedDate < Last_N_Days:7];
                if(!docs.isEmpty())
            delete docs;
    }
}

Thank you very much
Would someone be able to help me write test code for this trigger:
trigger ReferralCreateContact on Lead (after insert) {
    if (trigger.isinsert){
        if (trigger.isafter){
    for (lead ld : trigger.new){
        if (ld.nextofkin__c !=null && ld.Emergency_Contact_Phone__c !=null){
            String first;
            String last;
            
            String s = ld.NextofKin__c;
            String [] lines = s.split(' ');
            first = lines[0];
            last = lines[1];
            
            List<Contact> contactToInsert = new List<contact>();
            Contact newContact = new Contact();
            newContact.RecordTypeId='0121N000001HoR7QAK';
            newContact.related_referral__c = ld.id;
            newContact.firstname = first;
            newContact.lastname = last;
            newContact.MobilePhone=ld.Emergency_Contact_Phone__c;
            newContact.recordtypeid= '0122g0000005rSbAAI';
            newContact.ownerid = ld.ownerid;
            
            contactToInsert.add(newContact);
              insert contactToInsert;       
        }
    }
    }
    }

}
I'm working on an integration to push files from Salesfroce to a different API, and am putting together a mockup JSON. Can someone help in how to write the JSON for files (ContentVersion or ContentDocument)? Can you please give an example for a syntax that would make sense, even with a fake example? This would be of great help. 
Hello, I am working on updating Salesforce records from an outside platform, and I need my:
1. SF Consumer Key
2. SF Consumer Secret
3. SF Token

How can I find what these are? 
I am new to integrations, so this may be a very basic question. I need to create a mock up of JSON of a sample Salesforce record, to ultimately be able to post to an external API. My question is: is there any required context for constructing the JSON? E.g. do the field names need to equal the API names in salesfroce (e.g. {
  "Lead" : [ {
    "bed_count__c" : 55}]}

Or- can I assign the fields any name I want? Apologies if this is very basic, but your assitance is greatly helpful. 
Can someone help- i need to rewrite the below trigger, with the same effects, but with remove all SOQL queries from inside the for loop:

trigger CdlUpdateDischarge on ContentDocumentLink (after insert) {
    Set <string> setlinkedid = new set<string>();
    for (ContentDocumentLink cd : trigger.new){
            setlinkedid.add(cd.linkedentityid);
        List<Discharge__c> disList = [select id from discharge__c where id=:setlinkedid];
        List<contentdocumentlink> cdl = [SELECT ContentDocumentId
                                     FROM ContentDocumentLink 
                                     WHERE LinkedEntityId in (select id from discharge__c where id=:setlinkedid)];
        try{
        if (cdl.size() > 0 && cdl.size() < 2){
            for (Discharge__c dis : disList){
            dis.Referrals_Status__c = 'Documents Uploaded';
            }
            update disList;
        }    
        }catch(exception e){
            system.debug(e);
        }
        
    }
    
}
Question- I added a visualfroce page to the page layout, and added it to the mobile cards section. I am seeing the page on an Ipad, but not on my iPhone. Why would that be?
Hello, I need to import old logged calls into Salesforce. I am doing tests in Sandbox, and every time I insert the records to the Task object, they appear in Salesforce as regular tasks, instead of as logged calls. Is there a way to get them to land as logged calls? Thank you. 
I am working on Process Builder. My criteria is that if a multi-select-picklist field on the lookup object is not blank, I want to populate this field with that value. 

I am entering this value in my action step but it won't let me save:
What do I need to change? Thank you. 

[Discharge__c].Referral_Name__c.Language__c 
I had built a trigger in Sandbox, which finds duplicates (with the same external id) and it creates a hyperlink (in the form of a date) on the new record, to be able to link to the old record. I will show you the piece of the code that does that below. However, I accidentally forgot to change the hyperlink from the sandbox link to the production link. I now need to change all the vlaues of those hyperlinks in production. I tried something in the execute anonymous window as a test, but it didn't seem to work. I'll show you both the piece of the Handler and the attempt that I made in the execute window. 

HANDLER:
                string pdi = discharge.Previous_instances__c;
                string disId = discharge.id;
                date disDate = discharge.Discharge_Date__c;
                integer day = oldDischargeMap.get(discharge.Id).Discharge_Date__c.day();
                integer month = oldDischargeMap.get(discharge.Id).Discharge_Date__c.month();
                integer year = oldDischargeMap.get(discharge.Id).Discharge_Date__c.year();
                string dateDisplay = month + '/' + day + '/' + year;
                if(pdi == null){
                    pdi = '';}
                else{
                    pdi = pdi;}
                
                newDischarge.previous_instances__c = pdi+' '+ '<a href=https://centers--partial.lightning.force.com/'+disId+'>'+dateDisplay+ '</a>' + ' ; ' ;

EXECUTE TRIAL
list<discharge__c> disch = [select previous_instances__c from discharge__c ];
for (discharge__c dis: disch){
    if (dis.previous_instances__c != null){
    string link = dis.previous_instances__c;
    link = link.replace('<a href=https://centers--partial.lightning.force.com/', '<a href=https://centers.lightning.force.com/');
    dis.previous_instances__c = link;
        update dis;
    }}
 
I created a VF page, and when I "edit page" and drage the VF component to the page, I select the page name from the "Visualforce Page Name" drop down, yet when I click save, I get a pop up with this error: "Component 'Visualforce' has an invalid value for property 'Visualforce Page Name'." What would the problem be? The page is enabled for lightning, so I don't know what else could be causing this error?
When I try to drag my VF page to the lightning record page, and try to save, it gives this error: "Component 'Visualforce' has an invalid value for property 'Visualforce Page Name'."  What is the problem?
I am trying to create a VF page that has a sets of controlling picklists. CBO_Type controls CBO_Name. when I try to display the page, I get this error: "The inline edit-enabled dependent picklist 'CBO Name' requires its controlling field 'CBO Type' to be present on the page." 

Here is my page and controller extension....

Page:
<apex:page standardController="Discharge__c" extensions="DischargeCboRelatedExtension" lightningStylesheets="true">
<apex:form >
        <apex:pageBlock title="{!Discharge__c.Name}'s - CBOs" mode="inlineEdit" >
            <apex:pageBlockButtons location="top" >
                <apex:commandButton style="background:lightblue" value="New CBO" action="/003/e?retURL={!discharge__c.id}&accid={!discharge__c.id}" />
                <apex:commandButton style="background:lightblue" action="{!save}" value="Save" id="saveButton" />
                <apex:commandButton style="background:lightblue" onclick="resetInlineEdit()" id="cancelButton" value="Cancel" />
            </apex:pageBlockButtons>
              <apex:pageBlockTable value="{!cbos}" var="item" style="background:skyblue">
                   <apex:column headerValue="Action" >
                            <apex:outputLink value="/{!item.id}/e?retURL=/apex/accountDisplay/{!Discharge__c.id}" target="_parent">Edit
                            </apex:outputLink>&nbsp;|&nbsp;
                           
                     <apex:outputLink value="{!URLFOR($Action.Contact.Delete, item.id)}&retURL=%2F{!Discharge__c.id}" target="_parent" onclick="return window.confirm('Are you sure?'); ">Delete
                      </apex:outputLink>       
                 </apex:column>  
                  
                                       
                <apex:column value="{! item.referral_date__c}" />
                <apex:column value="{!item.CBO_Type__c}" />
                <apex:column value="{! item.cbo_name__c}" />
                <apex:column value="{!item.Referral_Status__c}" /> 
                 <apex:column value="{!item.rejection_cancellation_reason__c}" />
                  <apex:column value="{!item.Start_of_Service__c}" />
                  <apex:column value="{!item.End_of_Service__c}" />
               
             <!--   <apex:column headerValue="Phones" >
                    <apex:outputField value="{!item.CBO_Type__c}">
                    <apex:inlineEditSupport showOnEdit="saveButton,cancelButton"
                        hideOnEdit="editButton" event="ondblclick"
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                </apex:outputField>

                </apex:column> -->
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class DischargeCboRelatedExtension {
    public List<Cbo__c> cbos {get;set;}

        public DischargeCboRelatedExtension(ApexPages.StandardController stdController) {
        this.cbos = [select id,cbo_type__c, cbo_name__c, cbo_address__c, phone_number__c,fax_number__c,referral_date__c,referral_status__c,rejection_cancellation_reason__c,start_of_service__c,end_of_service__c,secondary_organization__c from CBO__c where Discharge_Name__c =:stdController.getId()];

    }
        public PageReference save() {
        update cbos ;
        return null;
    }
}
Hello, Would someone be able to assist in writing a test class for the following apex class:
global class purgeFiles implements Schedulable{
    
    global void execute(SchedulableContext SC) {
        
    List<ContentDocumentLink > docs;
        docs = [SELECT Id, Linkedentity.name, Linkedentity.id,ContentDocument.CreatedDate  
                FROM contentDocumentLink 
                WHERE Linkedentityid 
                IN (SELECT Id FROM lead where createddate < Last_N_Days:7 and isconverted = false) ];  
                //may want to change to include ALL leads
                //AND ContentDocument.CreatedDate < Last_N_Days:7];
                if(!docs.isEmpty())
            delete docs;
    }
}

Thank you very much
Hello, our Contact object has a lookup to our Lead object. When a Lead is inserted or updated, and certain custom fields are not null, a trigger automatically creates a Contact record. One of those custom Lead fields is a rich text area, because after the Contact is inserted, we want to turn that into a hyperlink which can be clicked on to go straight to the Contact record. What would you advise as the best way to do this? Any help in building the trigger would be greatly appreciated. 
Hello, we have a trigger on Lead that creates a Contact based on 2 fields from the Lead . After the Contact is inserted, we want to turn the Lead field that contains the name of the Contact to turn into a hyperlink with a link to that Contact record. I built a trigger, but it is not working, and I am not sure why not. Can someone please help. Here is the trigger:

trigger ContactsTrigger on Contact (after insert) {
     // add mobilephone to set and assign id variable
    Set<String> contactNumSet = new Set<String>();
    Id newConId;
    for (contact c : trigger.new){
        if (c.mobilephone != null){
            newConId = c.id;
            contactNumSet.add(c.mobilephone);
        }
    }
 //query related lead   
 List<Lead> refsToInvestigate = new List<Lead>();       
 List<Lead> refsToUpdate = new List<Lead>();  
 String nok1;
    refsToInvestigate = [select emergency_contact_phone__c from Lead where emergency_contact_phone__c = :contactNumSet];    
        for (Lead ref : refsToInvestigate){
                nok1 = ref.NextofKin__c; }
    
    for (Lead refer : refsToInvestigate){
                refer.nextofkin__c =  '<a href=https://centers--partial.lightning.force.com/'+newConId+'>'+nok1+ '</a>' ;
        refsToUpdate.add(refer);  } 
         update refsToUpdate;

}
Hello, I need some help assigning the owner of Contact records because of the way in which I am creating these records in the first place. We have an integration built which automatically creates Leads. Now, we have a Trigger (on Lead) that picks up information in some custom Lead fields, and based on those creates new Contact records. 

I want the owner of the Contact record to ALWAYS be the same as the owner of the Lead record. The reason this is complicated is because immediately when Leads are generated by our integration, they are at first (in the first milisecond) owned by the person's account who built the integration. Then, we have a Lead Process Builder that changes the Lead owner based on certain criteria. However, since  in our scenario, the Contact records are being generated from a Lead trigger (which comes before Process Builder in the order of execution), the owner of the Contact keeps being assigned to the ORIGINAL lead owner (the account of the integration builders.) I tried using Contact Process Builder to assign the owner of the contact based on the parent Lead's owner, but that doesn't seem to be working.  What would you advise? 
This may be a basic question, but I need to manipulate a string. I have a string that is a phone number in this format: +18888888888. I need it to become 888-888-8888. How can I do so?
Thank you!
Hello, I have a process builder set up that posts a chatter notification to the Owner of the Lead when a certain custom field gets updated. How can I @mention that user in the body of the chatter post FROM process builder? The reason I need to do so is because I want the user to receive an alert (both a bell on the chatter and an email) when this chatter post gets posted?  FYI the person is always the User-Owner of the Lead record. Your help is greatly appreciated. 
Hello, I have a trigger that updates a Lead field checkbox (to true.) When that checkbox is checked off, I need to send a chatter notification to the owner of that record. What is the best way to do that? Can it be done with workflow rules? I'm afraid if I use process builder, it will fire off several times, because my Lead process is set to fire whenever a record is updated, which I think can sometimes fire more than once even if a field is only update once (unless there's a way to prevent that?) Can it be done in the trgiger itself? What would you recomend?
Would someone be able to help me write test code for this trigger:
trigger ReferralCreateContact on Lead (after insert) {
    if (trigger.isinsert){
        if (trigger.isafter){
    for (lead ld : trigger.new){
        if (ld.nextofkin__c !=null && ld.Emergency_Contact_Phone__c !=null){
            String first;
            String last;
            
            String s = ld.NextofKin__c;
            String [] lines = s.split(' ');
            first = lines[0];
            last = lines[1];
            
            List<Contact> contactToInsert = new List<contact>();
            Contact newContact = new Contact();
            newContact.RecordTypeId='0121N000001HoR7QAK';
            newContact.related_referral__c = ld.id;
            newContact.firstname = first;
            newContact.lastname = last;
            newContact.MobilePhone=ld.Emergency_Contact_Phone__c;
            newContact.recordtypeid= '0122g0000005rSbAAI';
            newContact.ownerid = ld.ownerid;
            
            contactToInsert.add(newContact);
              insert contactToInsert;       
        }
    }
    }
    }

}
I'm working on an integration to push files from Salesfroce to a different API, and am putting together a mockup JSON. Can someone help in how to write the JSON for files (ContentVersion or ContentDocument)? Can you please give an example for a syntax that would make sense, even with a fake example? This would be of great help. 
Hello, I am working on updating Salesforce records from an outside platform, and I need my:
1. SF Consumer Key
2. SF Consumer Secret
3. SF Token

How can I find what these are? 
I am new to integrations, so this may be a very basic question. I need to create a mock up of JSON of a sample Salesforce record, to ultimately be able to post to an external API. My question is: is there any required context for constructing the JSON? E.g. do the field names need to equal the API names in salesfroce (e.g. {
  "Lead" : [ {
    "bed_count__c" : 55}]}

Or- can I assign the fields any name I want? Apologies if this is very basic, but your assitance is greatly helpful. 
Can someone help- i need to rewrite the below trigger, with the same effects, but with remove all SOQL queries from inside the for loop:

trigger CdlUpdateDischarge on ContentDocumentLink (after insert) {
    Set <string> setlinkedid = new set<string>();
    for (ContentDocumentLink cd : trigger.new){
            setlinkedid.add(cd.linkedentityid);
        List<Discharge__c> disList = [select id from discharge__c where id=:setlinkedid];
        List<contentdocumentlink> cdl = [SELECT ContentDocumentId
                                     FROM ContentDocumentLink 
                                     WHERE LinkedEntityId in (select id from discharge__c where id=:setlinkedid)];
        try{
        if (cdl.size() > 0 && cdl.size() < 2){
            for (Discharge__c dis : disList){
            dis.Referrals_Status__c = 'Documents Uploaded';
            }
            update disList;
        }    
        }catch(exception e){
            system.debug(e);
        }
        
    }
    
}
Question- I added a visualfroce page to the page layout, and added it to the mobile cards section. I am seeing the page on an Ipad, but not on my iPhone. Why would that be?
Hello, I need to import old logged calls into Salesforce. I am doing tests in Sandbox, and every time I insert the records to the Task object, they appear in Salesforce as regular tasks, instead of as logged calls. Is there a way to get them to land as logged calls? Thank you. 
I am working on Process Builder. My criteria is that if a multi-select-picklist field on the lookup object is not blank, I want to populate this field with that value. 

I am entering this value in my action step but it won't let me save:
What do I need to change? Thank you. 

[Discharge__c].Referral_Name__c.Language__c 
I had built a trigger in Sandbox, which finds duplicates (with the same external id) and it creates a hyperlink (in the form of a date) on the new record, to be able to link to the old record. I will show you the piece of the code that does that below. However, I accidentally forgot to change the hyperlink from the sandbox link to the production link. I now need to change all the vlaues of those hyperlinks in production. I tried something in the execute anonymous window as a test, but it didn't seem to work. I'll show you both the piece of the Handler and the attempt that I made in the execute window. 

HANDLER:
                string pdi = discharge.Previous_instances__c;
                string disId = discharge.id;
                date disDate = discharge.Discharge_Date__c;
                integer day = oldDischargeMap.get(discharge.Id).Discharge_Date__c.day();
                integer month = oldDischargeMap.get(discharge.Id).Discharge_Date__c.month();
                integer year = oldDischargeMap.get(discharge.Id).Discharge_Date__c.year();
                string dateDisplay = month + '/' + day + '/' + year;
                if(pdi == null){
                    pdi = '';}
                else{
                    pdi = pdi;}
                
                newDischarge.previous_instances__c = pdi+' '+ '<a href=https://centers--partial.lightning.force.com/'+disId+'>'+dateDisplay+ '</a>' + ' ; ' ;

EXECUTE TRIAL
list<discharge__c> disch = [select previous_instances__c from discharge__c ];
for (discharge__c dis: disch){
    if (dis.previous_instances__c != null){
    string link = dis.previous_instances__c;
    link = link.replace('<a href=https://centers--partial.lightning.force.com/', '<a href=https://centers.lightning.force.com/');
    dis.previous_instances__c = link;
        update dis;
    }}
 
When I try to drag my VF page to the lightning record page, and try to save, it gives this error: "Component 'Visualforce' has an invalid value for property 'Visualforce Page Name'."  What is the problem?