• Pedro Garcia 26
  • NEWBIE
  • 30 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 8
    Replies
Hi,

I found the following action in the Audit Trail Log:
Organization setup action: sendViaGmailPrefOffOn has changed.

What does it mean?
Thanks,
Pedro
I'm using the Platform event as part of the integration with other systems.
An external system pushes to the Salesforce platform event and sends the data using REST; Salesforce returns the result of this.
My question:
Could I modify the REST response of the Platform event?

Thanks,
Pedro
Hi...
I've request GET at https://worldweather.wmo.int/en/json/2951_en.json
I'm receiving the following error when the JSON is parsed

common.apex.runtime.impl.ExecutionException: For input string: \"\"

It happens in the JSON element: ,"url":"www.meteo.go.ke\/"

How could I remove the "\/" character?
or
What other solution do you recommend to me?

Thanks,
Pedro
Hi...

I'm working in Cloud Services it's not an NPSP environment.

The business requirement is growing and converting into more complex.

I've been reading and testing the TDTM and I'm wondering if someone has the experience in adopting TDTM outside the NPSP.

Thanks,
Pedro
Hi...

The daily cases reported by the user are created every day. We want that the user receives this report by email with only his data. It means that the user can not receive any information about the cases created by another user.

How is possible to do this?

Thanks,
Pedro
Hi...

I need to make a report of the Daily Avg calculation. The service department wants to know how long the user has been connected to salesforce monthly.

Is it possible to do?
Thanks
Hi,
I have a custom object related to Case (lookup field)... I've created an LWC to edit some fields from my custom object on the Case record page.
Once the LWC is submitted I need to make the Case record page in Edit state and repopulate some field values.
Is it possible to do?
Thanks,
Hi...
I want to access to MailChimp data with OAuth 2.

I've found the following example at https://forceblogs.com/salesforce-integration-with-mailchimp-using-oauth-2-0/ but it doesn't work.

The error is because the line return null
var myPageRef = component.get("v.pageReference");

I appreciate any help

This is my modified code:
Helper
({
    doInit : function(component,Event,helper){
        var myPageRef = component.get("v.pageReference");

        console.log('here in doinit');

        console.log(myPageRef);
        var code = '';

        if(myPageRef != null){

           code = myPageRef.state.code;

           
        }

        console.log('this is the code'+code);
         
        var url = window.location.href;

        console.log(url);
        console.log(code);

        console.log(JSON.parse(myPageRef));
        if(code!=null && code.trim().length!=null && code!=undefined){
            var action=component.get("c.doFetchAccessToken");
            action.setParams({
                'code' : code,
                'redirectUri' : url.substr(0, url.indexOf('?'))
            });

            console.log('code '+code);
            console.log('redirectUri '+url.substr(0, url.indexOf('?')));
            action.setCallback(this, function(response){
                var state =response.getState();
                if(state==='SUCCESS'){
                    var res = response.getReturnValue();
                    component.set('v.accessToken',res);
                }
            });
            $A.enqueueAction(action);
        }
    },
    handleClick : function(component, event, helper) {
        var action=component.get("c.connectToMailchimp");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state =response.getState();
            if(state==='SUCCESS'){
                var res = response.getReturnValue();
                //console.log('URL FOR Mailchimp LOGIN-'+res.url);
                if(res.Error === undefined) {
                    console.log('Mailchimp Login Started');
                    window.open(res.url, '_top');
                }
                else if (res.Error != undefined && res.Error != null){
                    
                }
            } else if (state === 'ERROR'){
                console.log('Mailchimp Login Failed: ERROR');
            }
        });
        $A.enqueueAction(action);
    }
    
})

Client Controller
({	
    doInit : function(component, event, helper) {
		console.log('doinit ... ...');
    	helper.doInit(component, event, helper);
    },
	handleClick : function(component, event, helper) {
		helper.handleClick(component, event, helper);
	}
})

cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:isUrlAddressable" 
                access="global"
                controller = "MailChimpOAuth">
    <aura:attribute name="accessToken" type="String" />
    <aura:attribute name="pageReference" type="Object"/>
    <aura:handler name='init' value='{!this}' action='{!c.doInit}' />
    <div class = 'slds-grid slds-wrap slds-align_absolute-center' style="background-color:white;height:15rem;width:25rem;">
        <div class = 'slds-col slds-size_12-of-12 slds-align_absolute-center'>
            <lightning:button variant="brand" label="Connect To MailChimp" title="Base action" onclick="{! c.handleClick }"/><br></br>
        </div>
        <div class = 'slds-align_absolute-center'>
            Access Token is : {!v.accessToken}
        </div>
    </div>
</aura:component>

ApexClass
​​​​​​​
public class MailChimpOAuth {
    public static String clientId;
    public static String clientSecret;  
    @AuraEnabled
    public static Map<String, String> connectToMailchimp () {
        Map<String, String> returnMap = new Map<String, String>();

        MailChimp_Config__c gmc = getConfig();

        clientId = gmc.Client_ID__c;
        clientSecret = gmc.Secrect_ID__c;

        System.debug('logLevel');
        try{
            
            String redirectURI = 'https://speed-dream-189-dev-ed.lightning.force.com/lightning/n/Guije_Start';
            String url= 'https://login.mailchimp.com/oauth2/authorize';
            url+='?response_type=code&client_id='+clientId+'&redirect_uri='+ EncodingUtil.urlEncode(redirectURI, 'UTF-8');
            returnMap.put('url',url);
        } catch(Exception ex) {
            system.debug('Exception Error');
            system.debug(ex.getLineNumber()+':'+ex.getMessage()+':'+ex.getCause());
            returnMap.put('Error','Exception error while generating url'+'Line:'+ex.getLineNumber()+':Message '+ex.getMessage()+': Cause '+ex.getCause());
        }
        return returnMap;
    }   

    public static GUIJE_MailChimp_Config__c getConfig(){

        List<MailChimp_Config__c> gmc = [Select id, name, Client_ID__c, Secrect_ID__c, Code__c from MailChimp_Config__c];

        return gmc.get(0);
    }

    @AuraEnabled
    public static String doFetchAccessToken(String code, String redirectUri){

        MailChimp_Config__c gmc = getConfig();

        clientId = gmc.Client_ID__c;
        clientSecret = gmc.Secrect_ID__c;

        if(!String.isBlank(code)){

            gmc.code__c = code;

            update gmc;
        }
        

        System.debug('logLevel');
               
        String getTokenEndpoint = 'https://login.mailchimp.com/oauth2/token';
        String oAuthCode = code;
        String requestBody = 'grant_type=authorization_code&client_id='+clientId+'&client_secret='+clientSecret+'&redirect_uri='+EncodingUtil.urlEncode(redirectUri, 'UTF-8')+'&code='+code;
        String errorMessage ='';
        HttpRequest httpReq = new HttpRequest();
        HttpResponse httpRes = new HttpResponse();
        Http http = new Http();
        httpReq.setMethod('POST');
        httpReq.setEndPoint(getTokenEndpoint);
        httpReq.setBody(requestBody);
        
        try{
            httpRes = http.send(httpReq);
            
            if(httpRes.getStatusCode() == 200){
                Map<String, Object> response_Map = (Map<String, Object>)JSON.deserializeUntyped(httpRes.getBody());
                system.debug('response: '+httpRes.getBody());
                return String.valueOf(response_Map.get('access_token'));
            }else{
                system.debug('Unexpected Error with Mailchimp API'+
                             'Status '+httpRes.getStatus()+' and Status Code '+httpRes.getStatuscode());
            }
        }catch(System.Exception e){
            if(String.valueOf(e.getMessage()).startsWith('Unauthorized endpoint')){
                errorMessage = 'Unauthorize endpoint'
                    +'Goto Remote Site Setting and add '+' '+ getTokenEndpoint +' Endpoint';
                system.debug( errorMessage);
                //return null;
            }else{
                errorMessage = 'Unexpected Error'
                    +'Status '+httpRes.getStatus()+' and Status Code '+httpRes.getStatuscode();
                system.debug(errorMessage);
                //return null;
            }
        }
        return httpRes.getBody();
    }
}

Thanks,
Hi,

I need to run a batch to identify all the duplicates that were inserted before the duplicate rule was created.

We have more than 1M of records, I create a batch to find the duplicate using the Datacloud.FindDuplicates.findDuplicates class.

But it doesn't work with a high volume of data.
global with sharing class FuzzyMatchBatch  implements Database.Batchable<SObject> {
 
    global final String Query;
    global static Datacloud.FindDuplicatesResult[] results;
    global static List<Account> accountDuplicates = new List<Account>();

 
    global FuzzyMatchBatch(){
    }
 
    global Database.QueryLocator start(Database.BatchableContext BC){
       return Database.getQueryLocator([SELECT id, first_name__c, last_name__c, billingstreet FROM Account ]);
    }
 
    global void execute(Database.BatchableContext BC, List<Account> scope){

        results = Datacloud.FindDuplicates.findDuplicates(scope);

        for (Datacloud.FindDuplicatesResult findDupeResult : results) {
          System.debug(findDupeResult);
            for (Datacloud.DuplicateResult dupeResult : findDupeResult.getDuplicateResults()) {
              System.debug(dupeResult);
              for (Datacloud.MatchResult matchResult : dupeResult.getMatchResults()) {
                System.debug(matchResult);
                for (Datacloud.MatchRecord matchRecord : matchResult.getMatchRecords()) {
                    System.debug('Duplicate Record: ' + matchRecord.getRecord());

                    accountDuplicates.add((Account) matchRecord.getRecord());
                }
              }
            }
          }
     }
 
    global void finish(Database.BatchableContext BC){
    }
}

 
Hi...

I'm creating a Lightning component and use the Cytospace javascript library from https://cytoscape.org/
 
<ltng:require scripts="{!join(',', 
                $Resource.cytoscape + '/cytoscape.min.js', 
                $Resource.cytoscape + '/cytoscape.cjs.js')}"
                afterScriptsLoaded="{!c.setup}"/>

I got the following error: Custom Script Eval error in 'ltng:require' [SecureDOMEvent: [object Event] {key: {namespace":"c"}}]

I just follow the SF documentation at https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_libs_platform.htm

How could I validate if the Cytospace library can be used or not in Salesforce?

Thanks
Hi...

Based on the documentation at https://help.salesforce.com/articleView?id=real_time_event_monitoring_overview.htm&type=5 (https://help.salesforce.com/articleView?id=real_time_event_monitoring_overview.htm&type=5) I could access to the real-time event.

But it's not working... I want to know when any user access to specific URI in salesforce, for example, the permission setting page.

Thanks,
Pedro
Hi...

I'm working on a project for a huge organization. They requested an Unlocked package to deploy in Sandbox and later in production. I don't have access to DEV HUB and I never will be.
How could I do it? I have access to Sandbox.

Is there a way to create an Unlocked package on this scenario?

Thanks,
Pedro
Hi...

I've created a wrong Transaction Security policy in sandbox. Now, nobody can not log in including System administrator. How could I fix it?

Thanks
Hi..

Is DebugApex applicable in Develop edition?

I got the following message with I try to debug:
you exceeded your licensed number of debugging session. please end other session or purchase more.

Should I pay it? or I can debug it with my Develop Edition?

Thanks
Hi...

I'm creating a Lightning component and use the Cytospace javascript library from https://cytoscape.org/
 
<ltng:require scripts="{!join(',', 
                $Resource.cytoscape + '/cytoscape.min.js', 
                $Resource.cytoscape + '/cytoscape.cjs.js')}"
                afterScriptsLoaded="{!c.setup}"/>

I got the following error: Custom Script Eval error in 'ltng:require' [SecureDOMEvent: [object Event] {key: {namespace":"c"}}]

I just follow the SF documentation at https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_libs_platform.htm

How could I validate if the Cytospace library can be used or not in Salesforce?

Thanks
Hi...

The daily cases reported by the user are created every day. We want that the user receives this report by email with only his data. It means that the user can not receive any information about the cases created by another user.

How is possible to do this?

Thanks,
Pedro
Hi,

I need to run a batch to identify all the duplicates that were inserted before the duplicate rule was created.

We have more than 1M of records, I create a batch to find the duplicate using the Datacloud.FindDuplicates.findDuplicates class.

But it doesn't work with a high volume of data.
global with sharing class FuzzyMatchBatch  implements Database.Batchable<SObject> {
 
    global final String Query;
    global static Datacloud.FindDuplicatesResult[] results;
    global static List<Account> accountDuplicates = new List<Account>();

 
    global FuzzyMatchBatch(){
    }
 
    global Database.QueryLocator start(Database.BatchableContext BC){
       return Database.getQueryLocator([SELECT id, first_name__c, last_name__c, billingstreet FROM Account ]);
    }
 
    global void execute(Database.BatchableContext BC, List<Account> scope){

        results = Datacloud.FindDuplicates.findDuplicates(scope);

        for (Datacloud.FindDuplicatesResult findDupeResult : results) {
          System.debug(findDupeResult);
            for (Datacloud.DuplicateResult dupeResult : findDupeResult.getDuplicateResults()) {
              System.debug(dupeResult);
              for (Datacloud.MatchResult matchResult : dupeResult.getMatchResults()) {
                System.debug(matchResult);
                for (Datacloud.MatchRecord matchRecord : matchResult.getMatchRecords()) {
                    System.debug('Duplicate Record: ' + matchRecord.getRecord());

                    accountDuplicates.add((Account) matchRecord.getRecord());
                }
              }
            }
          }
     }
 
    global void finish(Database.BatchableContext BC){
    }
}

 
Hello Developers

My Requirement is that Reports must be sent through email with csv attachments, i have refered several blogs,

Basically Report needs to go in email with csv format, i have designed a apex class, but i dont know how to excute it in ananomus window
 
global class sendreport implements System.Schedulable {
    global void execute(SchedulableContext sc) {
        ApexPages.PageReference report = new ApexPages.PageReference('00O2w000002RDbUEAW'); //this id of the report
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('report.xls');
        attachment.setBody(report.getContent());
        attachment.setContentType('text/csv');
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
        message.setSubject('Report');
        message.setPlainTextBody('The report is attached.');
        message.setToAddresses( new String[] { 'manjunath.s@proseraa.com' } );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );
        
    }
 }
Any help please?

 
Hi...

Based on the documentation at https://help.salesforce.com/articleView?id=real_time_event_monitoring_overview.htm&type=5 (https://help.salesforce.com/articleView?id=real_time_event_monitoring_overview.htm&type=5) I could access to the real-time event.

But it's not working... I want to know when any user access to specific URI in salesforce, for example, the permission setting page.

Thanks,
Pedro
Hi...

I'm working on a project for a huge organization. They requested an Unlocked package to deploy in Sandbox and later in production. I don't have access to DEV HUB and I never will be.
How could I do it? I have access to Sandbox.

Is there a way to create an Unlocked package on this scenario?

Thanks,
Pedro
Hi...

I've created a wrong Transaction Security policy in sandbox. Now, nobody can not log in including System administrator. How could I fix it?

Thanks
Hi..

Is DebugApex applicable in Develop edition?

I got the following message with I try to debug:
you exceeded your licensed number of debugging session. please end other session or purchase more.

Should I pay it? or I can debug it with my Develop Edition?

Thanks