• Michael M
  • SMARTIE
  • 1650 Points
  • Member since 2019

  • Chatter
    Feed
  • 1
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 197
    Questions
  • 381
    Replies
This code doesnt work.



trigger CreateCase on Contact (before insert) {
 
    List<Case> listCase = new List<Case>();
     for(Contact a : Trigger.New) {  
          listCase.add(new Case(
          AccountID=a.AccountID,        
          ContactID = a.Name,
          Priority ='High',
          Origin = 'Phone',
          Status = 'Working')); 
          }
       
     if(listCase.size() > 0)
  {
        insert listCase;
    }
}
Are there any common ID's on ListEmail and EmailStatus classes? 

My task is to get the emailstatuses of list emails sent through a campaign. I know that ListEmail class can get the CampaignID. But now I need to get the Email Statuses of those emails. Is that possible? I would be able to do it by the ownerid of the listemail or by the campaignid.  Are there any common fields between listemail and emailstatus?
Hello, would someone be able to show me how to write test code for this basic controller extension:

public class CampaignEmailHistoryExtension {
public final Campaign thisCampaign;
 
    Public List<ListEmail> listEmails {get; set;}
 
    Public CampaignEmailHistoryExtension(ApexPages.StandardController stdController){
        this.thisCampaign = (Campaign)stdController.getRecord();

        try{
  
            Campaign camp=[Select Id, Name from Campaign where Id = :this.thisCampaign.id];
        
        listEmails = [SELECT ID, campaignId, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, subject, LastViewedDate
                      FROM ListEmail 
                      WHERE  campaignId IN (Select id from Campaign where Id = :this.thisCampaign.id)];
        }
        catch(exception e){
            Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL, 'No old records'));
        }       
}
}
Hello, I have written some apex code that currently does 3 things:
1) fetches the results of EmailStatuses for listemails 
2) puts that into a csv
3) emails that csv

I need to do a 4th thing: I need to summarize the results on the body of the email itself. In other words, I need to organize the queried data by "emailstatus.task.subject", and for each different subject, I need to show a summary of: 
1. number of contacts it was sent to
2. number of contacts who opened the email

Is this possible, and can you please show me how to do so. Here is my code so far:

// fetch Data using SOQL from Salesforce
List<Contact> contList = [Select id, name, CreatedDate, lastModifiedDate, email,
                           (SELECT  id, taskId, createdDate, firstOpenDate, lastOpenDate, timesOpened, emailTemplateName, task.subject, task.TaskSubtype
                          FROM EmailStatuses where createddate = last_month and task.tasksubtype = 'ListEmail')
                          from Contact where email != null ];
//Set Header values of the file
string csvHeader = 'Contact Name, Contact Email    , Subject, Date Sent, Times Opened, Task Subtype \n';
string mainContent = csvHeader;
for (Contact cnt: contList){
    for (emailstatus es : cnt.EmailStatuses){
        integer month = es.createddate.month();
        integer year = es.createddate.year();
    integer day = es.createddate.day();
        if (month == 12 && year == 2020 && day == 8){
      //Adding records in a string
       string recordString = cnt.name+','+cnt.email +','+es.task.subject +','+es.CreatedDate+','+es.timesOpened +','+es.task.tasksubtype +'\n';
       mainContent += recordString;
        }}}
Messaging.EmailFileAttachment csvAttcmnt = new Messaging.EmailFileAttachment ();

//Create CSV file using Blob
blob csvBlob = Blob.valueOf (mainContent);
string csvname= 'Contact.csv';
csvAttcmnt.setFileName (csvname);
csvAttcmnt.setBody (csvBlob);
Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();
String [] toAddresses = new list<string> {'test@test.org'};
//Set recipient list
singEmail.setToAddresses (toAddresses);
String subject ='Contact CSV';
singEmail.setSubject (subject);
singEmail.setPlainTextBody ('Contact CSV');

//Set blob as CSV file attachment
singEmail.setFileAttachments (new Messaging.EmailFileAttachment []{csvAttcmnt});
Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
Hello, I have apex code that collects the EmailStatus for listemails tha thave been sent. I would like to trigger this to send 3 days after a ListEmail is sent. Is that possible, and if so how?

Here is my code, if this helps to visualize what I am talking about:
// fetch Data using SOQL from Salesforce
List<Contact> contList = [Select id, name, CreatedDate, lastModifiedDate, email,
                           (SELECT  id, taskId, createdDate, firstOpenDate, lastOpenDate, timesOpened, emailTemplateName, task.subject, task.TaskSubtype
                          FROM EmailStatuses where createddate = last_month and task.tasksubtype = 'ListEmail')
                          from Contact where email != null ];
//Set Header values of the file
string csvHeader = 'Contact Name, Contact Email    , Subject, Date Sent, Times Opened, Task Subtype \n';
string mainContent = csvHeader;
for (Contact cnt: contList){
    for (emailstatus es : cnt.EmailStatuses){
        integer month = es.createddate.month();
        integer year = es.createddate.year();
    integer day = es.createddate.day();
        if (month == 12 && year == 2020 && day == 8){
      //Adding records in a string
       string recordString = cnt.name+','+cnt.email +','+es.task.subject +','+es.CreatedDate+','+es.timesOpened +','+es.task.tasksubtype +'\n';
       mainContent += recordString;
        }}}
Messaging.EmailFileAttachment csvAttcmnt = new Messaging.EmailFileAttachment ();

//Create CSV file using Blob
blob csvBlob = Blob.valueOf (mainContent);
string csvname= 'Contact.csv';
csvAttcmnt.setFileName (csvname);
csvAttcmnt.setBody (csvBlob);
Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();
String [] toAddresses = new list<string> {'me@comp.org'};
//Set recipient list
singEmail.setToAddresses (toAddresses);
String subject ='Contact CSV';
singEmail.setSubject (subject);
singEmail.setPlainTextBody ('Contact CSV');

//Set blob as CSV file attachment
singEmail.setFileAttachments (new Messaging.EmailFileAttachment []{csvAttcmnt});
Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
Does Salesforce have cPanel access? Or the equivalent? 
Hello, would someone be able to show me how to write test code for this class of mine: 

public with sharing class FetchCurrentURL {

 public class VisitorUrlOutput {
    @InvocableVariable(required=false)
    public String urlOfMostRecentPage;
  }

 @InvocableMethod(label='Get Current URL' description='Returns Current URL')
 public static List<String> getcurrentURL() {
   System.debug(URL.getSalesforceBaseUrl().toExternalForm());
   return new List<String>{URL.getSalesforceBaseUrl().toExternalForm()};
   }
 }
Hello, I am building an einstein bot, and I want to get the url (window.location.href) of the chatbot in the MIDDLE of the einstein bot dialogue (and therefore extraprechatformdetails won't do the job here.) Einstein bots allow invoking either apex or a flow in the middle of a dialogue. My question is: can I run javascript from a flow or apex class, so that I can get the window.location.href and save it as a variable that I can reference in my bot dialogue?
Hello, is there a way to integrate a live google spreadsheet with salesforce? So that the live updates show up in SF?
Hello, I am trying to invoke an apex class to get the current user's URL, from my chatbot dialogue. Here is my apex class. It does not seem to work- when it gets to that point in the chatbot, the bot sort of shuts down and says no agent is available. Am I doing this correctly?
public with sharing class BotUrlClass {
public class TranscriptInput {
    @InvocableVariable(required=true)
    public ID routableID;
    
  }
  
  public class VisitorUrlOutput {
    @InvocableVariable(required=true)
    public String urlOfMostRecentPage;
      
  }
 
  @InvocableMethod(label='Get User URL')
  public static List<VisitorUrlOutput> getUrlName(List<TranscriptInput> transcripts) {
 
    List<VisitorUrlOutput> urls = new List<VisitorUrlOutput>();
  
    for (TranscriptInput transcript : transcripts) {
    
      // Query for the transcript record based on the ID
      LiveChatTranscript transcriptRecord = [SELECT Name, URL__c
                                             FROM LiveChatTranscript 
                                             WHERE Id = :transcript.routableID 
                                             LIMIT 1];
        
        string headerdata2= ApexPages.currentPage().getHeaders().get('Host');
        string urlvalue2=Apexpages.currentPage().getUrl();
        string url2='https://' + headerdata2+ urlvalue2;  
        
      
      // Store the url in an output variable
      VisitorUrlOutput urlData = new VisitorUrlOutput();
      urlData.urlOfMostRecentPage = url2;
      
      // Add the url to the list of outputs
      urls.add(urlData);
    }
    
    return urls;
  }
}
Hello, is it possible to use a lightning flow to get the user's current url (equivalent of javascript's window.location.href), using  a lightnign flow? If not, is it possible with apex (not visualforce)?
Hello, I'm trying to change the background color of the actual messages themselves (the blue box below) on my einstein bot. I don't see this anywhere in the custom branding. Is this possible to change?
User-added image
Hello, I have apex class like this:

public class TwilioChatterConversationClass {
public static void ContactPostChatter(Id contactRecordId, string message){  
        if (flag == true){
        flag = false;
        Contact c = [ Select id, name, related_referral__r.ownerid, related_referral__r.name, related_Referral__r.Referral_Account__r.name From Contact Where Id =: contactRecordId];

        ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
        ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
        ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
        ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

        messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
        
        mentionSegmentInput.id = c.related_referral__r.ownerid;
    
//hyperlink        
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ c.id;   
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
linkInput.url = fullFileURL;
linkInput.urlName = c.name;
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput; 
//

        messageBodyInput.messageSegments.add(mentionSegmentInput);

 //  textSegmentInput.text = 'Referral, "' + c.related_referral__r.name  +  '".         Next of Kin,' + c.name +', has responded to your text: ' + message + ' To view their record <a href=https://centers.lightning.force.com/'+c.Id+'>click here.</a>' ;
   textSegmentInput.text = 'Referral, "' + c.related_referral__r.name  +  '".         Next of Kin,' + c.name +', has responded to your text: ' + message;
    messageBodyInput.messageSegments.add(textSegmentInput);

        feedItemInput.body = messageBodyInput;
        feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
        feedItemInput.subjectId = c.related_referral__r.ownerid;
        
    
ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);
    return;
}
}
}
}

I'm trying test code like this, but it's not covering the class (see screenshot below). Any idea why not?

@isTest
public class TwilioTriggerTest {
@isTest
    static void TwilioTest(){
        contact c = new contact();
        c.lastname = 'Test';
        c.MobilePhone = '123456789';
        c.Responded_to_first_message__c = true;
        insert c;

        TwilioChatterConversationClass.ContactPostChatter(c.id, 'hey');
}}

User-added image
 
We want to send out email surveys to a number of our Contacts. We don't have the requisite licenses to use the OOB Surveys feature. Is there a way to build this out with apex and a VF email template, without involving communities or sites? What would you recommend?
Hello, We have an object called Admissions. Admissions has 2 lookup fields to Account: Insurance Company and Secondary Insurance Company. In my custom report, I want the "child", or secondary, object to be "Admissions (Insurance Company)". However that is not an option when I am trying to create the report type. For some reason, "Admissions (Secondary Insurance Company)" is an option. How can I get "Admissions (Insurance Company)" to be an option?
Hello, I am create a chatter via ConnectApi in Apex, and I am using a linkInput. The issue is that it just looks like a blue box, when we want (need :) it to look like when a task is logged (because we are triggert this connectApi post after inserting a task via apex.) Here is the snippet of code, what it looks like, and what we want it to look like:

Snippet:
        ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
          String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ tsk.id;
        linkInput.url = fullFileURL;
        linkInput.urlName = tsk.type_referral__c;
        ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
        feedElementCapabilitiesInput.link = linkInput;
        feedItemInput.capabilities = feedElementCapabilitiesInput; 

How it looks:
User-added image

How we want it to look:
User-added image
Hello, we have some simple apex code that creates a task record, and the whoid of the task is a Lead. 

My question is: Just as when a regular activity is logged, it automatically posts to chatter with a summary of the activity, I need to do the same here. Specifically, I need it to post to the chatter on the Lead record page. Can this be done?
Hello, I want to be able to add a new "button" as an option to the arrow that appears in the list views (see picture). The option I want to add is simply a button that, when clicked on, displays 2 fields from the Lead object, and allows the user to update those fields right there, quick and easy. My questions are:
1) How would I create such a button?
2) how can I add it to the menu option from that arrow?
User-added image
Hello, I have the following apex class that I want to invoke from my einstein bot. Can someone help me with writing the test class for this code? 

public with sharing class BotUrlClass {
public class TranscriptInput {
    @InvocableVariable(required=true)
    public ID routableID;
  }
  
  public class VisitorUrlOutput {
    @InvocableVariable(required=true)
    public String url;
  }
 
  @InvocableMethod(label='Get User Name')
  public static List<VisitorUrlOutput> getUserName(List<TranscriptInput> transcripts) {
 
    List<VisitorUrlOutput> urls = new List<VisitorUrlOutput>();
  
    for (TranscriptInput transcript : transcripts) {
    
      // Query for the transcript record based on the ID
      LiveChatTranscript transcriptRecord = [SELECT Name, URL__c
                                             FROM LiveChatTranscript 
                                             WHERE Id = :transcript.routableID 
                                             LIMIT 1];
      
      // Store the first name in an output variable
      VisitorUrlOutput urlData = new VisitorUrlOutput();
      urlData.url = transcriptRecord.URL__c;
      
      // Add the name to the list of outputs
      urls.add(urlData);
    }
    
    return urls;
  }
}
Hello, I am setting up my first einstein bot... We have a dialogue that presents a menu. When the user clicks on one of the menu items (also a dialogue) we want it to automatically redirect the user to a new webpage. How can I build this into the bot/dialogue?
I am parsing JSON that is coming back from  REST callout, and when running, it is throwing this error: attempt to de-reference null object. The issue seems to be with how I am parsing the JSON, but I am not sure where I am going wrong. Can someone help?

Here is the snippet of the JSON I am parsing:
"result": {
"first_name": "JOHN",
"last_name": "SMITH",
"id_type": "MI",
"subscriber_id": "1234567",
"gender": "M",
"birthdate": "19601119",
"address": {
"info": "123 Main St.",
"city": "New York",
"state": "NY",
"zip_code": "100000"
},
"county:": {
"value": "14"
},
"office": {
"value": "H78"
},
"recert_month": {
"value": "12",
"name": "December"
},
"dates": [
{
"name": "Service",
"qualifier": "472",
"date": "2020-09-29"
},
{
"name": "Plan Begin",
"qualifier": "346",
"date": "2020-09-01"
},
{
"name": "Issue",
"qualifier": "102",
"date": "2020-06-01"
}
],


Here is how I am parsing it (bold part is causing error):
  
        Map<String, Object> wholeResponse = (Map<String, Object>) JSON.deserializeUntyped(response2.getBody());
            Map<String, Object> result = (Map<String, Object>) wholeResponse.get('result');
                Map<String, Object> residentAddress = (Map<String, Object>) result.get('address');
                   Map<String, Object> county = (Map<String, Object>) result.get('county');
                  Map<String, Object> office = (Map<String, Object>) result.get('office');
                 Map<String, Object> recert_month = (Map<String, Object>) result.get('recert_month');
        
       Eligibility__c newEligRec = new Eligibility__c(); 
        newEligRec.Referral_Name__c = ref.id;
        newEligRec.First_Name__c = string.valueof(result.get('first_name'));
        newEligRec.Last_Name__c = string.valueof(result.get('last_name'));
        newEligRec.Name_Id_Type__c = string.valueof(result.get('id_type'));
        newEligRec.Client_ID__c = string.valueOf(result.get('subscriber_id'));
        newEligRec.Gender__c = string.valueOf(result.get('gender'));
        string birthdate;
              if (string.valueof(result.get('birthdate')) != null){
                  birthdate = string.valueof(result.get('birthdate')).remove('-');
                  string year = birthdate.substring(0,4);
                  string month = birthdate.substring(4,6);
                  string day = birthdate.substring(6,8);
                 birthdate = month + '/' + day + '/' + year;
                    }
        newEligRec.Date_of_Birth__c = birthdate;
        newEligRec.Address_Number_and_Street__c = string.valueOf(residentAddress.get('info')); 
        newEligRec.City__c =  string.valueOf(residentAddress.get('city'));    
        newEligRec.State__c =  string.valueOf(residentAddress.get('state'));    
        newEligRec.Zip_Code__c = string.valueOf(residentAddress.get('zip_code'));
        newEligRec.County__c = string.valueOf(county.get('value'));
        newEligRec.Office__c = string.valueOf(office.get('value'));
        newEligRec.Recertification_Month_value__c = string.valueOf(recert_month.get('value'));
        newEligRec.Recertification_Month__c = string.valueOf(recert_month.get('name'));
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
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?
Are there any common ID's on ListEmail and EmailStatus classes? 

My task is to get the emailstatuses of list emails sent through a campaign. I know that ListEmail class can get the CampaignID. But now I need to get the Email Statuses of those emails. Is that possible? I would be able to do it by the ownerid of the listemail or by the campaignid.  Are there any common fields between listemail and emailstatus?
Hello, would someone be able to show me how to write test code for this basic controller extension:

public class CampaignEmailHistoryExtension {
public final Campaign thisCampaign;
 
    Public List<ListEmail> listEmails {get; set;}
 
    Public CampaignEmailHistoryExtension(ApexPages.StandardController stdController){
        this.thisCampaign = (Campaign)stdController.getRecord();

        try{
  
            Campaign camp=[Select Id, Name from Campaign where Id = :this.thisCampaign.id];
        
        listEmails = [SELECT ID, campaignId, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, subject, LastViewedDate
                      FROM ListEmail 
                      WHERE  campaignId IN (Select id from Campaign where Id = :this.thisCampaign.id)];
        }
        catch(exception e){
            Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL, 'No old records'));
        }       
}
}
Hello, would someone be able to show me how to write test code for this class of mine: 

public with sharing class FetchCurrentURL {

 public class VisitorUrlOutput {
    @InvocableVariable(required=false)
    public String urlOfMostRecentPage;
  }

 @InvocableMethod(label='Get Current URL' description='Returns Current URL')
 public static List<String> getcurrentURL() {
   System.debug(URL.getSalesforceBaseUrl().toExternalForm());
   return new List<String>{URL.getSalesforceBaseUrl().toExternalForm()};
   }
 }
Hello, I am building an einstein bot, and I want to get the url (window.location.href) of the chatbot in the MIDDLE of the einstein bot dialogue (and therefore extraprechatformdetails won't do the job here.) Einstein bots allow invoking either apex or a flow in the middle of a dialogue. My question is: can I run javascript from a flow or apex class, so that I can get the window.location.href and save it as a variable that I can reference in my bot dialogue?
Hello, I am trying to invoke an apex class to get the current user's URL, from my chatbot dialogue. Here is my apex class. It does not seem to work- when it gets to that point in the chatbot, the bot sort of shuts down and says no agent is available. Am I doing this correctly?
public with sharing class BotUrlClass {
public class TranscriptInput {
    @InvocableVariable(required=true)
    public ID routableID;
    
  }
  
  public class VisitorUrlOutput {
    @InvocableVariable(required=true)
    public String urlOfMostRecentPage;
      
  }
 
  @InvocableMethod(label='Get User URL')
  public static List<VisitorUrlOutput> getUrlName(List<TranscriptInput> transcripts) {
 
    List<VisitorUrlOutput> urls = new List<VisitorUrlOutput>();
  
    for (TranscriptInput transcript : transcripts) {
    
      // Query for the transcript record based on the ID
      LiveChatTranscript transcriptRecord = [SELECT Name, URL__c
                                             FROM LiveChatTranscript 
                                             WHERE Id = :transcript.routableID 
                                             LIMIT 1];
        
        string headerdata2= ApexPages.currentPage().getHeaders().get('Host');
        string urlvalue2=Apexpages.currentPage().getUrl();
        string url2='https://' + headerdata2+ urlvalue2;  
        
      
      // Store the url in an output variable
      VisitorUrlOutput urlData = new VisitorUrlOutput();
      urlData.urlOfMostRecentPage = url2;
      
      // Add the url to the list of outputs
      urls.add(urlData);
    }
    
    return urls;
  }
}
Hello, is it possible to use a lightning flow to get the user's current url (equivalent of javascript's window.location.href), using  a lightnign flow? If not, is it possible with apex (not visualforce)?
Hello, I'm trying to change the background color of the actual messages themselves (the blue box below) on my einstein bot. I don't see this anywhere in the custom branding. Is this possible to change?
User-added image
Hello, I have apex class like this:

public class TwilioChatterConversationClass {
public static void ContactPostChatter(Id contactRecordId, string message){  
        if (flag == true){
        flag = false;
        Contact c = [ Select id, name, related_referral__r.ownerid, related_referral__r.name, related_Referral__r.Referral_Account__r.name From Contact Where Id =: contactRecordId];

        ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
        ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
        ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
        ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

        messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
        
        mentionSegmentInput.id = c.related_referral__r.ownerid;
    
//hyperlink        
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ c.id;   
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
linkInput.url = fullFileURL;
linkInput.urlName = c.name;
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput; 
//

        messageBodyInput.messageSegments.add(mentionSegmentInput);

 //  textSegmentInput.text = 'Referral, "' + c.related_referral__r.name  +  '".         Next of Kin,' + c.name +', has responded to your text: ' + message + ' To view their record <a href=https://centers.lightning.force.com/'+c.Id+'>click here.</a>' ;
   textSegmentInput.text = 'Referral, "' + c.related_referral__r.name  +  '".         Next of Kin,' + c.name +', has responded to your text: ' + message;
    messageBodyInput.messageSegments.add(textSegmentInput);

        feedItemInput.body = messageBodyInput;
        feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
        feedItemInput.subjectId = c.related_referral__r.ownerid;
        
    
ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);
    return;
}
}
}
}

I'm trying test code like this, but it's not covering the class (see screenshot below). Any idea why not?

@isTest
public class TwilioTriggerTest {
@isTest
    static void TwilioTest(){
        contact c = new contact();
        c.lastname = 'Test';
        c.MobilePhone = '123456789';
        c.Responded_to_first_message__c = true;
        insert c;

        TwilioChatterConversationClass.ContactPostChatter(c.id, 'hey');
}}

User-added image
 
Hello, We have an object called Admissions. Admissions has 2 lookup fields to Account: Insurance Company and Secondary Insurance Company. In my custom report, I want the "child", or secondary, object to be "Admissions (Insurance Company)". However that is not an option when I am trying to create the report type. For some reason, "Admissions (Secondary Insurance Company)" is an option. How can I get "Admissions (Insurance Company)" to be an option?
Hello, I am create a chatter via ConnectApi in Apex, and I am using a linkInput. The issue is that it just looks like a blue box, when we want (need :) it to look like when a task is logged (because we are triggert this connectApi post after inserting a task via apex.) Here is the snippet of code, what it looks like, and what we want it to look like:

Snippet:
        ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
          String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ tsk.id;
        linkInput.url = fullFileURL;
        linkInput.urlName = tsk.type_referral__c;
        ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
        feedElementCapabilitiesInput.link = linkInput;
        feedItemInput.capabilities = feedElementCapabilitiesInput; 

How it looks:
User-added image

How we want it to look:
User-added image
Hello, we have some simple apex code that creates a task record, and the whoid of the task is a Lead. 

My question is: Just as when a regular activity is logged, it automatically posts to chatter with a summary of the activity, I need to do the same here. Specifically, I need it to post to the chatter on the Lead record page. Can this be done?
Hello, I have the following apex class that I want to invoke from my einstein bot. Can someone help me with writing the test class for this code? 

public with sharing class BotUrlClass {
public class TranscriptInput {
    @InvocableVariable(required=true)
    public ID routableID;
  }
  
  public class VisitorUrlOutput {
    @InvocableVariable(required=true)
    public String url;
  }
 
  @InvocableMethod(label='Get User Name')
  public static List<VisitorUrlOutput> getUserName(List<TranscriptInput> transcripts) {
 
    List<VisitorUrlOutput> urls = new List<VisitorUrlOutput>();
  
    for (TranscriptInput transcript : transcripts) {
    
      // Query for the transcript record based on the ID
      LiveChatTranscript transcriptRecord = [SELECT Name, URL__c
                                             FROM LiveChatTranscript 
                                             WHERE Id = :transcript.routableID 
                                             LIMIT 1];
      
      // Store the first name in an output variable
      VisitorUrlOutput urlData = new VisitorUrlOutput();
      urlData.url = transcriptRecord.URL__c;
      
      // Add the name to the list of outputs
      urls.add(urlData);
    }
    
    return urls;
  }
}