• Andy Kallio 13
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 11
    Replies
Hello. I'm basically just an admin trying to figure out their first lwc by piecing together examples. Very little experinece with javascript. 

I am trying to do make a case form to run in a public community that will format phone numbers using a libphone library in apex. The call to apex is returning the expected data. I just can't seem to do anything with it after that. I just get undefined errros in the console. How do I use the value returned from the apex method (phoneInfo.E164) and assign it to my case.suppliedphone field for insert?

Thanks for any help!
 
import {
    LightningElement,
    track,
    api
} from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent} from 'lightning/platformShowToastEvent';
import { COUNTRIES_PICKLIST } from "c/libphoneData";
import getPhoneNumberInfo from "@salesforce/apex/communityCaseLWCUtility.getPhoneNumberInfo";

 
export default class CreateCase extends LightningElement {
    @api title;
    @api buttonlabel;
    showSuccessPage = false;
    btnDisabled = true;
    hasData = false;
    phoneInfo;
    phoneNumberE164;

    handleBlur() {
        const input = this.template.querySelector(".phone");
        this.disabled = !input.validity.valid;
    }
    
    handleSubmit(event) {
        const country     = this.template.querySelector(".country").value;
        const phoneNumber = this.template.querySelector(".phone").value;
        console.log('phone number '+phoneNumber);
        getPhoneNumberInfo({countryCode: country, userPhoneNumber: phoneNumber})
        .then(result => {
            this.phoneInfo = result;
            this.hasData = true;
        })
        .catch(error => console.log(error));
        const fields = event.detail.fields;
        fields.service_team__c = 'Customer Experience';
        fields.service_team_brand__c = 'RedBalloon';
        fields.recordtypeid = '0127F000000IQXBQA4';
        fields.status = 'New';
        fields.origin = 'RedBalloon Customer Community';
        fields.service_email__c = 'info@redballoon.com.au'
        fields.suppliedphone = this.phoneInfo.E164;
        console.log(JSON.stringify(fields));
        this.template.querySelector('lightning-record-edit-form').submit(fields);

        this.showSuccessPage = true;
        window.open('/customers/s/contactsupport','_top')
    }

    get countries() {
        return COUNTRIES_PICKLIST
    }

    set disabled(value) {
        this.btnDisabled = value;
    }

    get disabled() {
        return this.btnDisabled;
    }
    
}


The undefined Error happens when I try to set suppliedphone with the value returned from apex: 
 fields.suppliedphone = this.phoneInfo.E164;

 

Hello friends
I'm working with the QuickActionDefaultsHandler interface for the first time.

Just following the example set here:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_QuickAction_QuickActionDefaultsHandler.htm#apex_interface_QuickAction_QuickActionDefaultsHandler

I think I have what I want and now trying to write a test class which is turning about to be challenging.

Now as you can see in the class there is an if statement tests for the actiontype being 'SendEmail' 
defaults.get(j).getActionType().equals('SendEmail'))

And this works with the testing that I have done in the UI, but it does not work in my test class. For some reason in my test class the debug logs are showing that method is returning 'Email' and therefore not getting past the if statement. 

I don't understand why there is a difference, or see what I can do to fix it. 

Class:
global class EmailPublisherLoader implements QuickAction.QuickActionDefaultsHandler {

    // The main interface method
    global void onInitDefaults(QuickAction.QuickActionDefaults[] defaults) {
        QuickAction.SendEmailQuickActionDefaults sendEmailDefaults = null;
        system.debug('defaults '+defaults);
        // Check if the quick action is the standard Case Feed send email action
        for (Integer j = 0; j < defaults.size(); j++) {
            system.debug('sobject: '+defaults.get(j).getTargetSObject().getSObjectType());
            system.debug('Name: '+defaults.get(j).getActionName());
            system.debug('Type: '+defaults.get(j).getActionType());
            if (defaults.get(j) instanceof QuickAction.SendEmailQuickActionDefaults &&
                defaults.get(j).getTargetSObject().getSObjectType() == EmailMessage.sObjectType &&
                defaults.get(j).getActionType().equals('SendEmail')) {
                    sendEmailDefaults = (QuickAction.SendEmailQuickActionDefaults)defaults.get(j);
                    system.debug('defaults: '+sendEmailDefaults);
                    break;
            }
        }

        if (sendEmailDefaults != null) {
            Case c = [SELECT Status, 
                            Contact.Email, 
                            RecordType.Name,
                            Origin,
                            Service_Email__c 
                    FROM Case 
                    WHERE Id=:sendEmailDefaults.getContextId()];
            EmailMessage emailMessage = (EmailMessage)sendEmailDefaults.getTargetSObject();
            system.debug('in reply to: '+sendEmailDefaults.getInReplyToId());
            

            //if replying to an email then use original emails subject and include the original email
            if(sendEmailDefaults.getInReplyToId() == null) {
                sendEmailDefaults.setInsertTemplateBody(false);
                sendEmailDefaults.setIgnoreTemplateSubject(false);
            } else {
                sendEmailDefaults.setInsertTemplateBody(true);
                sendEmailDefaults.setIgnoreTemplateSubject(true);
            }

            sendEmailDefaults.setTemplateId(getTemplateIdHelper(c.service_email__c));

        }
    }

    private Id getTemplateIdHelper(String serviceEmail) {
        Id templateId = null;
        try {
            templateId = [select id, 
                                 Email_Template_Id__c 
                            from Case_Feed_Default_Email_Template__mdt
                            where Service_Email__c = :serviceEmail limit 1].Email_Template_Id__c;
        } 
        catch (Exception e) {
            system.debug('Unble to locate EmailTemplate using name: ' +
            serviceEmail + ' refer to Setup | Communications Templates '
            + serviceEmail);
        }
        return templateId;
    }
}

Test Class:
@isTest
public class EmailPublisherLoader_Test {
    
    static testMethod void rbnCustomer() {

        //setup test data
        boolean doInsert = true;
        case_TestData_Director director = new case_TestData_Director();
        Case cs = director.construct(new case_TestData_RBNCustomer(), doInsert);

        list<QuickAction.QuickActionDefaults> defaults = new list<QuickAction.QuickActionDefaults>();
        QuickAction.SendEmailQuickActionDefaults sendEmailDefaults = Test.newSendEmailQuickActionDefaults(cs.Id, null);
        defaults.add(sendEmailDefaults);
        Test.startTest();
            EmailPublisherLoader cntl = new EmailPublisherLoader();
            cntl.onInitDefaults(defaults);
        Test.stopTest();
        EmailMessage emailMessage = (EmailMessage) sendEmailDefaults.getTargetSObject();
        System.assertNotEquals(null, emailMessage);
        
        
     
    }
}

​​​​​​​

Hello friends. 

I have just started working in a service cloud  org that is using  two different embedded service deployments for chat. One is used on a public salesforce community, and the other is embedded on a website.

There are two different code snippets, but the section in which the pre-chat settings are defined are the same. This is being used to find/create Contacts and populate some custom fields on the LiveChatTranscript record. 

I first noticed that the custom fields on LiveChatTranscript were not being populated very consitently. Then I found that the community deployment fails to populate thef fields most of them (93% failure), and that the website deployment works most of the the time (3% failure).

 

Looking across both sets of records, I have not able to find a consistent difference between the two that might serve as a clue into what is going wrong with our community deployement. So, now looking to the community for some ideas. Thanks!

Here is what the code snippet looks like for the community deployment.

 

window._snapinsSnippetSettingsFile = (function() {
console.log("Snippet settings file loaded.");	// Logs that the snippet settings file was loaded successfully
//liveagent.enableLogging(); //console errors on this line. therefore have no logs in console.
embedded_svc.settings.extraPrechatFormDetails = [{
	"label":"First Name",
	"transcriptFields":["PreChat_First_Name__c"]
	}, {
	"label":"Last Name",
	"transcriptFields":["PreChat_Last_Name__c"]
	}, {
	"label":"Email",
	"transcriptFields":["PreChat_Email__c"]
	}, {
	"label":"ChatStartSite",
	"value":"ADR-Website",
	"transcriptFields":["Chat_Start_Site__c"],
	}, {
	"label":"Brand",
	"value":"Adrenaline",
	"transcriptFields":["Brand__c"],
	}, {
	"label":"RecordTypeId",
	"value":"0127F000000ESNFQA4",
	}];

embedded_svc.settings.extraPrechatInfo = [{
			"entityFieldMaps": [{
				"doCreate": true,
				"doFind": false,
				"fieldName": "LastName",
				"isExactMatch": false,
				"label": "Last Name"
			}, {
				"doCreate": true,
				"doFind": false,
				"fieldName": "FirstName",
				"isExactMatch": false,
				"label": "First Name"
			}, {
				"doCreate": true,
				"doFind": true,
				"fieldName": "Email",
				"isExactMatch": true,
				"label": "Email"
			}],
			"entityName": "Contact",
			"saveToTranscript": "Contact",
			"showOnCreate": true
		}];

})();
Hello friends. Working with chat/embedded services for the first time. We are trying to first make a chat work in a community with this simple snippet. With this snippet we are able to initiate a chat session. So, on the surface it seems ok, but the pre-chat fields are not being set, and the contact matching and creation is not working.

The expected outcome is a new contact of certain record type if one is not already not found that has an exact match for email and recordtype.

The actual outcome is a new contact of a different recordtype than the one defined in this snippet. 

My theory on why this is happening is that the recordtype that the record is being created with is the default record type of the 'Automated Process' user. However, it seems impossible to prove this because salesforce makes it impossible to see the profile configuration of Automated Process user. 


Also, the pre-chat custom fields on livechattranscript are not being populated. 

 
window._snapinsSnippetSettingsFile = (function() {
console.log("Snippet settings file loaded.");	// Logs that the snippet settings file was loaded successfully
liveagent.enableLogging(); //console errors on this line. therefore have no logs in console.
embedded_svc.settings.extraPrechatFormDetails = [{
	"label":"First Name",
	"transcriptFields":["PreChat_First_Name__c"]
	}, {
	"label":"Last Name",
	"transcriptFields":["PreChat_Last_Name__c"]
	}, {
	"label":"Email",
	"transcriptFields":["PreChat_Email__c"]
	}, {
	"label":"ChatStartSite",
	"value":"ADR-Website",
	"transcriptFields":["Chat_Start_Site__c"],
	}, {
	"label":"Brand",
	"value":"Adrenaline",
	"transcriptFields":["Brand__c"],
	}, {
	"label":"RecordTypeId",
	"value":"0127F000000ESNFQA4",
	}];

embedded_svc.settings.extraPrechatInfo = [{
			"entityFieldMaps": [{
				"doCreate": true,
				"doFind": false,
				"fieldName": "LastName",
				"isExactMatch": false,
				"label": "Last Name"
			}, {
				"doCreate": true,
				"doFind": false,
				"fieldName": "FirstName",
				"isExactMatch": false,
				"label": "First Name"
			}, {
				"doCreate": true,
				"doFind": true,
				"fieldName": "Email",
				"isExactMatch": true,
				"label": "Email"
			}, {
				"doCreate": true,
				"doFind": true,
				"fieldName": "RecordTypeId",
				"isExactMatch": true,
				"label": "RecordTypeId"
			}],
			"entityName": "Contact",
			"saveToTranscript": "Contact",
			"showOnCreate": true
		}];

})();


Any suggestions are appreciated.

Thanks!
Hello friends.
I just came across a process builder in a new org for me, and one of the nodes has a condition on EmailMessage.MessageIdentifier.

Is there anybody out there that can tell me what this field is for?

The documentation says it is The ID of the email message.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_emailmessage.htm

However, I can see lots of records where this field is null, and there is also the standard Id field. Understanding that this field is doing will help me figure out what this process builder is supposed to be doing, hopefully.  Thanks!
 
Hello friends!

We have an un-authenticated community which has a global quick action for the guest site user to create Case records. 

And, we have process builders and a flow to perform some business logic upon the creation of those records, and they are not performing as expected.

The basics of the problem is that Case.ContactId is being set when it shouldn't be. 
  1. I am having a difficult time getting a useful debug log. I have set trace flags on the Site Guest User and Automated Processes. Only receiving logs for the guest user and they have very little information. I can't seem to get a log for Automated Processes
  2. Because of that challenge, I have used a custom object called Flow_Log__c to make my own logs. From this I can see that Case ContactId is already set upon entering process builder. I think this expected behavior with email-to-case, but not a global action.

I cannot find/think of where else Case.ContactId could be set before hitting process builder. I have looked at the workflow rules and there is only 1 trigger. I cannot see what this trigger is supposed to do because it's in a managed package, but I have reasons for believing it's not that. 


So, I am just looking for some tips on getting a debug log and some ideas on what could be setting this field. 

BTW, I also tried creating the case with an execute anonymous script,and then business logic works as expected. 

Hello friends. A very beginner question on Platform Events. My org is using Process Builder to send Platform Events that are being consumed by another system. 

The developers of that system are now asking if we can include deletes. Process Builder cannot do that. My first idea is to write a before trigger on the object that would create a new platform event of the same type but with new a field that would indicate the event as 'DELETE'.  However, I don't know if using the Streaming API is the better way to go because I have no experience with that. 

 

So, just looking for a little advice from someone that has that experience. Thanks!

Hi all,
we have had the following configuration which has worked prior to Summer '21:

#1: External Services schema JSON:

{
  "swagger": "2.0",
  "info": {
    "title": "title",
    "description": "API for host",
    "version": "0.0.1"
  },
  "securityDefinitions": {
    "JWT": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization"
    }
  },
  "security": [
    {
      "JWT": []
    }
  ],
  "tags": [
    {
      "name": "V1",
      "description": "Operations about V1"
    }
  ],
  "host": "hostName",
  "schemes": [
    "https"
  ],
  "paths": {
    "/graphql": {
      "post": {
        "tags": [
          "V1"
        ],
        "description": "Graphql post",
        "operationId": "graphqlPost",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "description": "Authorization",
            "required": true,
            "type": "string"
          },
          {
            "name": "BodyModel",
            "in": "body",
            "description": "BodyModel",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "string"
            }
          }
        },
        "security": []
      }
    }
  },
  "definitions": {}
}

#2: Basic Named Credentials which have "Authentication Protocol" as "No Authentication"

#3 Flow which utilizes the #1 and #2 so it can make some API requests with Authorization: Bearer <api key> in the header and some JSON body.

 

After Summer '21, without anything being changed on the above 3 points, API requests started failing.

We have debugged and figured out that Flow will not send the Authorization header anymore (although it shows in the flow debug log that it is there). Headers named other than "Authorization" will pass.

I can not find anything in the release notes pointing me to the exact change and required adaptations in order for this to work again.

Does anyone know what change should External Service JSON maybe have in order for Auth header to be compatible with Summer '21 changes?

 

Thanks

Hello. I'm basically just an admin trying to figure out their first lwc by piecing together examples. Very little experinece with javascript. 

I am trying to do make a case form to run in a public community that will format phone numbers using a libphone library in apex. The call to apex is returning the expected data. I just can't seem to do anything with it after that. I just get undefined errros in the console. How do I use the value returned from the apex method (phoneInfo.E164) and assign it to my case.suppliedphone field for insert?

Thanks for any help!
 
import {
    LightningElement,
    track,
    api
} from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent} from 'lightning/platformShowToastEvent';
import { COUNTRIES_PICKLIST } from "c/libphoneData";
import getPhoneNumberInfo from "@salesforce/apex/communityCaseLWCUtility.getPhoneNumberInfo";

 
export default class CreateCase extends LightningElement {
    @api title;
    @api buttonlabel;
    showSuccessPage = false;
    btnDisabled = true;
    hasData = false;
    phoneInfo;
    phoneNumberE164;

    handleBlur() {
        const input = this.template.querySelector(".phone");
        this.disabled = !input.validity.valid;
    }
    
    handleSubmit(event) {
        const country     = this.template.querySelector(".country").value;
        const phoneNumber = this.template.querySelector(".phone").value;
        console.log('phone number '+phoneNumber);
        getPhoneNumberInfo({countryCode: country, userPhoneNumber: phoneNumber})
        .then(result => {
            this.phoneInfo = result;
            this.hasData = true;
        })
        .catch(error => console.log(error));
        const fields = event.detail.fields;
        fields.service_team__c = 'Customer Experience';
        fields.service_team_brand__c = 'RedBalloon';
        fields.recordtypeid = '0127F000000IQXBQA4';
        fields.status = 'New';
        fields.origin = 'RedBalloon Customer Community';
        fields.service_email__c = 'info@redballoon.com.au'
        fields.suppliedphone = this.phoneInfo.E164;
        console.log(JSON.stringify(fields));
        this.template.querySelector('lightning-record-edit-form').submit(fields);

        this.showSuccessPage = true;
        window.open('/customers/s/contactsupport','_top')
    }

    get countries() {
        return COUNTRIES_PICKLIST
    }

    set disabled(value) {
        this.btnDisabled = value;
    }

    get disabled() {
        return this.btnDisabled;
    }
    
}


The undefined Error happens when I try to set suppliedphone with the value returned from apex: 
 fields.suppliedphone = this.phoneInfo.E164;

 

I am creating a rather complex questionnaire in flow. 

I've noticed a rather odd behaviuor...see the following example:

Q1. Do you have kids?
Yes/No (choice Yes=Truie, choice No=False)

Q2. are you kids at school? (the component visibility for this Q is set if Q1=Yes)
Yes/No

Now, I can finally create a kids profile record

The Kids Profile object includes Q1 and Q2 checkboxes so that I can map to the actual screen questions.

Here is the problem, if I map both Q1 and Q2 on the create records component, but the response for Q1 happens to be No, Q2 gets skipped and in the debug Q2 results to be a null, and consequently a  INVALID_TYPE_ON_FIELD_IN_RECORD error will occur. 

Considering that I know why the error is being triggered, I believe that for a screen funtionality, there should actually be something that ignore the mapping for skipped questions; I can't believe this is not a stardad functionality...

Please let me know if it's just me that I am missing something or it's really like that. 
 

Hello friends. Working with chat/embedded services for the first time. We are trying to first make a chat work in a community with this simple snippet. With this snippet we are able to initiate a chat session. So, on the surface it seems ok, but the pre-chat fields are not being set, and the contact matching and creation is not working.

The expected outcome is a new contact of certain record type if one is not already not found that has an exact match for email and recordtype.

The actual outcome is a new contact of a different recordtype than the one defined in this snippet. 

My theory on why this is happening is that the recordtype that the record is being created with is the default record type of the 'Automated Process' user. However, it seems impossible to prove this because salesforce makes it impossible to see the profile configuration of Automated Process user. 


Also, the pre-chat custom fields on livechattranscript are not being populated. 

 
window._snapinsSnippetSettingsFile = (function() {
console.log("Snippet settings file loaded.");	// Logs that the snippet settings file was loaded successfully
liveagent.enableLogging(); //console errors on this line. therefore have no logs in console.
embedded_svc.settings.extraPrechatFormDetails = [{
	"label":"First Name",
	"transcriptFields":["PreChat_First_Name__c"]
	}, {
	"label":"Last Name",
	"transcriptFields":["PreChat_Last_Name__c"]
	}, {
	"label":"Email",
	"transcriptFields":["PreChat_Email__c"]
	}, {
	"label":"ChatStartSite",
	"value":"ADR-Website",
	"transcriptFields":["Chat_Start_Site__c"],
	}, {
	"label":"Brand",
	"value":"Adrenaline",
	"transcriptFields":["Brand__c"],
	}, {
	"label":"RecordTypeId",
	"value":"0127F000000ESNFQA4",
	}];

embedded_svc.settings.extraPrechatInfo = [{
			"entityFieldMaps": [{
				"doCreate": true,
				"doFind": false,
				"fieldName": "LastName",
				"isExactMatch": false,
				"label": "Last Name"
			}, {
				"doCreate": true,
				"doFind": false,
				"fieldName": "FirstName",
				"isExactMatch": false,
				"label": "First Name"
			}, {
				"doCreate": true,
				"doFind": true,
				"fieldName": "Email",
				"isExactMatch": true,
				"label": "Email"
			}, {
				"doCreate": true,
				"doFind": true,
				"fieldName": "RecordTypeId",
				"isExactMatch": true,
				"label": "RecordTypeId"
			}],
			"entityName": "Contact",
			"saveToTranscript": "Contact",
			"showOnCreate": true
		}];

})();


Any suggestions are appreciated.

Thanks!
Hello friends.
I just came across a process builder in a new org for me, and one of the nodes has a condition on EmailMessage.MessageIdentifier.

Is there anybody out there that can tell me what this field is for?

The documentation says it is The ID of the email message.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_emailmessage.htm

However, I can see lots of records where this field is null, and there is also the standard Id field. Understanding that this field is doing will help me figure out what this process builder is supposed to be doing, hopefully.  Thanks!
 
Hello friends!

We have an un-authenticated community which has a global quick action for the guest site user to create Case records. 

And, we have process builders and a flow to perform some business logic upon the creation of those records, and they are not performing as expected.

The basics of the problem is that Case.ContactId is being set when it shouldn't be. 
  1. I am having a difficult time getting a useful debug log. I have set trace flags on the Site Guest User and Automated Processes. Only receiving logs for the guest user and they have very little information. I can't seem to get a log for Automated Processes
  2. Because of that challenge, I have used a custom object called Flow_Log__c to make my own logs. From this I can see that Case ContactId is already set upon entering process builder. I think this expected behavior with email-to-case, but not a global action.

I cannot find/think of where else Case.ContactId could be set before hitting process builder. I have looked at the workflow rules and there is only 1 trigger. I cannot see what this trigger is supposed to do because it's in a managed package, but I have reasons for believing it's not that. 


So, I am just looking for some tips on getting a debug log and some ideas on what could be setting this field. 

BTW, I also tried creating the case with an execute anonymous script,and then business logic works as expected. 
Hi all,

I need to add gif in the pdf page.
I tried to add but it is not working anyone know what is the issue ?

Thanks in advance

Hi,

I have created a very basic form via Flow component, to enable community user to create Cases from Community and to attach files to the case.
The flow is visible and works fine for users logged in. 
However it is not visible for guest users even if the page containing the flow is public. And I have already give Read and Write acces on cases to the guest user. Would you know please what kind of set up I need to do to make this flow visible for guest users? 

It seems to be possible: https://salesforcesidekick.com/2017/08/14/finally-a-flow-component-in-community-builder/

Many Thanks

Jalal