• Nachiket Deshpande 33
  • NEWBIE
  • 24 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 15
    Replies
I was checking https://trailhead.salesforce.com/en/modules/get_smart_einstein_feat/units/get_smart_einstein_feat_tour this TrailHead Module,
I want to know out of all 45 Endpoints availbale here https://metamind.readme.io/v2/docs , which one will help me to give Einstein Social Insights.
I am working on sentiment analysis where I get feedback from user and I wanted to highlight common words which are Trending for that perticular product feedback.
like following
User-added image

Please Advise.

I am making an HTTP POST request to external system, it works fine when I post request from Developer orgs, these orgs are of older versions. However when I build a package and install that package into a new org and when I try to connect to external system using HTTP POST I get this HandShake error.
Error: Something went wrong. Please try again.Remote host closed connection during handshake
One reason that I thought of is, Salesforce has disabled TLS 1.0 , Salesforce is requiring an upgrade to TLS 1.1 or higher by July 22, 2017 in order to align with industry best practices for security and data integrity. On that date it will disable TLS 1.0. But the API that I am hitting using post confirms that its still accepting TLSv1, handshake error result via open SSL, inside of external system network.

Does new Salesforce orgs that I am creating has TLS 1.1 or higher enabled by default? and external system is not accepting request because of change in version for TLS.

https://c.na34.visual.force.com/apex/MyVFPage <- this one succeeds on connectionhttps://packageNameSpace.ap5.visual.force.com/apex/MyVFPage <- this one fails These are callback URLS.
When I check the critical updates in my old org I can see like following:-
User-added image
However new Salesforce orgs that I am creating does not have this in Critical updates, does that mean new Salesforce orgs already having version of TLS 1.1 or higher enabled by default, if YES how to check version of TLS?

I did activate TLS 1.1 or higher under critical updates section assuming there might be some issue with TLS, also external system confirms that they accept TLS V1.0, V1.1,V1.2 and V1.3

When I tried to connect to external system after activating this update , all seems to be working fine in the old Salesforce orgs that I am using, however new Salesforce orgs that I am creating, having issue shaking hands with external system.

Any thoughts how to approach this issue.
Note: I can not post code here because of the security reasons, it will be helpful if anyone can guide me about this.

As most of the time we have to think of requirement to accomplished using out-of-Box feature like e.g process builder which we think of an alternative to trigger, but suppose I have to handle scenario of Delete using Process Builder then there is limitation!(e.g calculation of roll-up on Delete) so I am curious about what is that limitation because of which Delete scenario is not handled in Process Builder.

I am making an HTTP POST request to external system, it works fine when I post request from Developer orgs, these orgs are of older versions. However when I build a package and install that package into a new org and when I try to connect to external system using HTTP POST I get this HandShake error.
Error: Something went wrong. Please try again.Remote host closed connection during handshake
One reason that I thought of is, Salesforce has disabled TLS 1.0 , Salesforce is requiring an upgrade to TLS 1.1 or higher by July 22, 2017 in order to align with industry best practices for security and data integrity. On that date it will disable TLS 1.0. But the API that I am hitting using post confirms that its still accepting TLSv1, handshake error result via open SSL, inside of external system network.

Does new Salesforce orgs that I am creating has TLS 1.1 or higher enabled by default? and external system is not accepting request because of change in version for TLS.

https://c.na34.visual.force.com/apex/MyVFPage <- this one succeeds on connectionhttps://packageNameSpace.ap5.visual.force.com/apex/MyVFPage <- this one fails These are callback URLS.
When I check the critical updates in my old org I can see like following:-
User-added image
However new Salesforce orgs that I am creating does not have this in Critical updates, does that mean new Salesforce orgs already having version of TLS 1.1 or higher enabled by default, if YES how to check version of TLS?

I did activate TLS 1.1 or higher under critical updates section assuming there might be some issue with TLS, also external system confirms that they accept TLS V1.0, V1.1,V1.2 and V1.3

When I tried to connect to external system after activating this update , all seems to be working fine in the old Salesforce orgs that I am using, however new Salesforce orgs that I am creating, having issue shaking hands with external system.

Any thoughts how to approach this issue.
Note: I can not post code here because of the security reasons, it will be helpful if anyone can guide me about this.

Hi,

is there a way to optimized this code? I am having problem with bulk upload and these needs to be optimized, can you instruct me on what should be the proper way?
 
public static void populateLastestEnrollment(List<Case> pCase){
        Id EnrollmentRecordType = Schema.Sobjecttype.Case.getRecordTypeInfosByName().get('Enrollment').getRecordTypeId();
        Id DiscontinuedmentRecordType = Schema.Sobjecttype.Case.getRecordTypeInfosByName().get('Unenroll From GPS').getRecordTypeId();
        Id AdultPatient = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Adult Patient').getRecordTypeId();
        Id MinorPatient = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Minor Patient').getRecordTypeId();
        Id RECORDTYPEID_RELATIONSHIP_INDIVIDUAL = Schema.SObjectType.Relationship__c.getRecordTypeInfosByName().get('Individual Relationship').getRecordTypeId();
        
        List<Account> updatedAccountList = new List<Account>();
        Set<Id> caseAccountId = new Set<Id>();
        
        //Get the parent Account of the case
        for(Case cs : pCase){
            caseAccountId.add(cs.AccountId);
        }
        
        List<Account> caseAccountList = [SELECT Id, Latest_Enrollment_Unenrollment_Case__c, Consent_Provided__c,Consent_Version__c, Consent_Provided_Date__c, 
                                         Enrollment_Status_Text__c, Enrollment_Form_Received_Date__c, RecordTypeId, X18th_Birthdate__c, PersonMobilePhone, PersonHomePhone,
                                         (SELECT Id, GPS_Enrollment_Status_Detail__c, Date_Consent_Provided__c, GPS_Enrollment_Status__c, Enrollment_Type__c,
                                          Enrollment_Form_Received_Date__c, Consent_Version__c, CaseNumber, Consent_Provided__c, Consent_Provided_By__c,
                                          CreatedDate, Status, RecordTypeId, Case_Sub_Status__c FROM Cases ORDER BY CreatedDate ASC) 
                                         FROM Account WHERE Id IN: caseAccountId];
        
        //loop through all child records
        for(Account a : caseAccountList){
            //Checks if case object has records
            if(a.Cases.size() > 0){
                // find out which one is the most recent relevant case for a given patient account
                for(Case c : a.Cases){
                    if(c.CreatedDate >= mostRecentCase.CreatedDate || mostRecentCase.Id == null){
                        if(c.RecordTypeId == EnrollmentRecordType || 
                           (c.RecordTypeId == DiscontinuedmentRecordType
                            && c.Status == 'Closed'
                            && c.Case_Sub_Status__c == 'Completed')){
                                mostRecentCase = c;
                            }                     
                    }
                }
            }
            
            // If there is no relevant case available, then make the auto populated fields null:
            if(mostRecentCase.Id == null){
                a.Latest_Enrollment_Unenrollment_Case__c = null;
                a.Consent_Provided_Date__c = null;
                a.Consent_Expiration_Date__c = null;
                a.Consent_Provided__c = null;
                a.Consent_Version__c = null;
                a.Enrollment_Form_Received_Date__c = null;
                a.Enrollment_Status_Text__c = 'Never Enrolled';
            } else if(mostRecentCase.RecordTypeId == EnrollmentRecordType &&
                      (mostRecentCase.Enrollment_Type__c != 'New Consent' || mostRecentCase.Date_Consent_Provided__c != null)){
                a.Consent_Provided__c = mostRecentCase.Consent_Provided__c;
                a.Consent_Provided_Date__c = mostRecentCase.Date_Consent_Provided__c;
                a.Consent_Version__c = mostRecentCase.Consent_Version__c;
                if (a.Consent_Provided__c == null){
                    a.Consent_Expiration_Date__c = null;
                } else if (a.Consent_Provided__c == 'Verbal Consent') {
                    a.Consent_Expiration_Date__c = a.Consent_Provided_Date__c.addDays(30);
                } else if (a.Consent_Provided__c == 'Written Consent') {
                    if (a.X18th_Birthdate__c.addDays(30) < a.Consent_Provided_Date__c.addYears(10) && a.X18th_Birthdate__c > mostRecentCase.Date_Consent_Provided__c){ // Sheri updated add days
                        a.Consent_Expiration_Date__c = a.X18th_Birthdate__c.addDays(30); 
                    } else {
                        a.Consent_Expiration_Date__c = a.Consent_Provided_Date__c.addYears(10);
                    }
                }
                a.Consent_Expiration_Workflow_Reset__c = false;
                a.Enrollment_Status_Text__c = mostRecentCase.GPS_Enrollment_Status__c;
                a.Enrollment_Form_Received_Date__c = mostRecentCase.Enrollment_Form_Received_Date__c;       
                a.Latest_Enrollment_Unenrollment_Case__c = mostRecentCase.Id;
            } else if(mostRecentCase.RecordTypeId == DiscontinuedmentRecordType){
                a.Consent_Provided__c = null;
                a.Consent_Provided_Date__c = null;
                a.Consent_Expiration_Date__c = null;
                a.Consent_Version__c = null;
                a.Enrollment_Status_Text__c = mostRecentCase.GPS_Enrollment_Status__c;
                a.Latest_Enrollment_Unenrollment_Case__c = mostRecentCase.Id;
            }
            //Make sure that only 1 record will update the Parent
            updatedAccountList.add(a);
        }

        //update Account
        if(updatedAccountList.size() > 0){
                update updatedAccountList;
        }

    }

 
I m getting this error...Method must define a body at line 12 column 17

This is my class code
What should be my code??


public with sharing class GmailIntegrationController{
    public List<AccountWrapper> accountswrappers { get; set; }
    String code;
    String key;
    String secret;
    String redirect_uri;
    String CheckFlag;

public GmailIntegrationController(ApexPages.StandardController controller){
        init();
}
    public void init();
    {
        code=null;
        key = '195939611313-5cr46086hm5db9m17aqjuo6gqpok9a0j.apps.googleusercontent.com';
        secret = '2LX5IFSaXhh87gfjaLzz8tz1';
        redirect_uri = 'https://gmail.google.com';
        System.debug('shhdhshdhshdhshdhhd' + ApexPages.currentPage().getUrl());
        code = ApesPages.currentPage().getParameters().get('code');
        System.debug('dsdsjdsjdjsjdjsjdsjd' + code);
        accountWrappers = new List<AccountWrapper>();
            if(code != '' && code != null){
                authenticationAndUpload();
                    return;
            }
}
    public void authenticationAndUpload(){
        System.debug('codesdd:::' + code);
            if(code != '' && code != null)
            {
                System.debug('codesdd:::' + code);
                AccessToken();
            }
            }

public void AccesToken(){
    HttpRequest req = new HttpRequest();
    req.setMethod('POST');
    req.setEndpoint('https://accounts.google.com/o/oauth2/token');
    req.setHeader('content-type', 'application/x-www-form-urlencoded');
        String messageBody = 'code='+code+'&client_id='+key+'&client_secret='+secret+'&redirect_uri='+redirect_uri+'&grant_type=authorization_code';
 System.debug('messageBody::::' + messageBody );
        req.setHeader('Content-length', String.valueOf(messageBody.length()));
        req.setBody(messageBody);
        req.setTimeout(60*1000);

        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();
System.debug(' This is the reponse from google: ' + resp );
        String str = resp;
        List<String> lstStr = str.split(',');
        System.debug('@@@'+lstStr[0]);
        List<String> lstStr1 = lstStr[0].split(':');
        System.debug('###'+lstStr1[1]);
        String st = lstStr1[1].remove('"').trim();
        System.debug('@#@'+st);
        
        System.debug('JHSDHSDJSJDJSD'  + st + 'TETTETTETTE');
Http http = new Http();
        req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('');
        req.setHeader('content-type', 'text/csv');
        req.setHeader('Authorization','Bearer '+st);
        String contentGmail = gmailContent();
        req.setBody(contentGmail);  
        req.setTimeout(60*1000);
        HttpResponse respp = http.send(req);
}
public PageReference GmailAuth()
    {
        PageReference pg = new PageReference(GmailAuthUri (key , redirect_uri)) ;
        return pg;
    }
    
    public String GmailAuthUri(String Clientkey,String redirect_uri)
    {
        String key = EncodingUtil.urlEncode(Clientkey,'UTF-8');
        String uri = EncodingUtil.urlEncode(redirect_uri,'UTF-8');
        String authuri = '';
        authuri = 'https://accounts.google.com/o/oauth2/v2/auth?'+
     'scope = https://gmail.google.com/' +
     'state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&'+
     'redirect_uri=' +uri+
        '&response_type=code&'+
        'client_id='+key+
        '&access_type=offline';
        
        return authuri;
    }
    
    
    private String gmailContent(){
    
        String messageBodies = 'Number ,PTC,Last,First,Mid,Gender,Nationality,DOB,Passport No,Email,Phone\r';
        messageBodies+= 'Hello, Test , test, Test,Test, Test, Test,TEst\r';
        return messageBodies;
    }
 
    public class AccountWrapper{
   
        public Account account{get;set;}
        
        public AccountWrapper(Account account) {
            
            this.account = account;
        }
    }
}
I would like to pre-populate the account name for this record type with something so the user doesn’t have to be bothered with entering something there because it’s a required field. 
Hi All,

I am getting the below error in my community. I don't know how to handle this exception. 

The error message is: Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address).

Let me know how to handle this exception

Thanks,
Vijay
 
Getting the following issue while solving the Understand Cross-Site Scripting (XSS) trail under Understand Cross-Site Scripting (XSS) Module.

"There was an unhandled exception. Please reference ID: VNEMXUKK. Error: Faraday::ClientError. Message: INVALID_TYPE: select id from cvcs__c where name = 'xbc1' and ^ ERROR at Row:1:Column:16 sObject type 'cvcs__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names."

The cvcs__c is a custom setting.