• Cloud Atlas
  • NEWBIE
  • 275 Points
  • Member since 2014

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 59
    Replies
All of our Visualforce pages suddenly stopped displaying all fields and values. I see no changes made to the pages, the underlying classes, the objects and fields referenced, nor to guest profile permissions.
On the Salesforce side, the only message I see is that legacy SOAP API versions were retired today, but I don't see how that comes into play here. Furthermore, they say those versions are usable until the Winter '19 release (we are on Summer '18).

Has anyone seen this before?
I have been assigned with making sure nothing breaks while changing the global and user locale from english canada to english USA. From my understanding nothing would break during the change and it might not even be possible to test this? Any sudgestions on this? could somthing go wrong if so any recomendations on how to test this?  
Hi,
Does anyone know how to build a service which allows Kafka to push data into Salesforce?
Or maybe a service where Salesforce listens to Kafka changes via api and creates a record in one or more objects?
Any help is appreciated.
Thanks!
Hi.
I am seeking some info as to how to query publisherquerylanguageservice in google ad manager api and update records in SF.

I have gone over multiple docs , have seen bunch of videos, but am still utterly confused as to what should be the calling criteria/api for accessing the ad manager data.

Steps I have completed so far :
1. Have an ad manager account.
2. Created a projected in google console
3. Created credentials with correct redirect uri to get client secret/id
4. Used those credentials to get "bearer" token both in POSTMAN and OAuth playground.
5. And now using the token, when I calling api https://www.google.com/apis/ads/publisher/v202002/PublisherQueryLanguageService?wsdl , I am getting a success 200.

Beyond this, I am not making any headway as to what I should be querying and how to access the data. I am not even sure what's the correct api and format I should be using.
The more google articles I read, the more confused I am getting.
And most of the StackExchange and DeveloperForum links are targeted to getting a token rather than what needs to be done after getting the token.

If anyone has exprience, could you provide guidance as to how I can retrieve data.
The PublisherQueryLanguageService is huge and the data I am interested in is under https://developers.google.com/ad-manager/api/reference/v202002/PublisherQueryLanguageService#Programmatic_Buyer

Any help in this regards is appreciated.
Thanks!
Hello,

Disclaimer : I have read the all the documentation for sites, so please don't just post links.

I am just curious to hear from folks who have used Sites, as to the limitations surrounding it, like
  1. Can I build a site which accepts details and attachments (like a form) from site users , without the need for any additional license?
  2. Can I build workflows and approval processes around the records which were captured via sites?
  3. How many folks can access the site per month?
  4. What happens when site limits are breached?
  5. How many clicks to the site are allowed per day?
  6. How much should Aura compenents be involved in building sites or can it just be a simple VF page?
Things like that.
Any advice/information in this regards would be much appreciated.
Thanks!
I am trying to create a custom button on List View (Lightning) for sending emails to over 400 people ... All emails will contain personalized info so doing a cc and bulkifying email recepients isn't an option.

I have a custom button on a list view ( which is made up of a VF page) and has ability to select upto 400 records.
The controller for that page is working on a for-loop , but I still ended up with sendMail limit error (cannot execute more than 10 sendMail)

User-added image
public class ExpertEmailController {
	
   public sObject[] mAct; 
   ApexPages.StandardSetController selectedRec;
   String redirectUrl = System.Label.Redirect_Url;
    
   public ExpertEmailController(ApexPages.StandardSetController controller){
       controller.setPageSize(400);
       selectedRec = controller;
   }
   
    public PageReference sendMail(){
 
        // Send Email
        for ( Monthly_Activity__c ma : (Monthly_Activity__c[])selectedRec.getSelected() ){
        mAct = [SELECT Email
                FROM sObject
                WHERE Id =: ma.Id 
                LIMIT 1];
		            
        // Create body
            string body = 'Dear '+ mAct[0].User +', '+'\n\n';
            body += 'BODY'+'\n\n';

	    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(new String[] {mAct[0].Email});
            mail.setSenderDisplayName('Salesforce Administrator');
            mail.setSubject('Record');
            mail.setPlainTextBody(body);
            Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});   
        }  
		
        PageReference page = new PageReference(redirectUrl);
        page.setRedirect(true);
        return page;
    }
}

Not exactly sure how an I circumvent this limit.
Creating an out-of-the-box (WF based) email alert on a value update isn't also an option since the records will be locked.

If anyone has any idea, let me know.
Thanks in advance.
I have a service inserting records and accepting EST values.
"publishedAtEt": "2019-06-13T15:00:33",
"submittedAtEt": "2019-05-01T00:03:34",
Then I have a formula field to figure out the month for "submitted at" value.
INTEGER SUB_MONTH = MONTH(DATEVALUE( Submitted_At__c ))
But upon debugging , I am finding that the SUB_MONTH value is not 5, but 4.
USER_DEBUG |DEBUG|Sub_Month 4
Has anyone ever experienced something like that?
If yes, how did you resolve.
Any help is appreciated.
Thanks!

 
I am trying to send a record to an external system via Async service . Only one value within that payload needs to be an array while the remaining should be string. Does any one know how it can be done?
searlization looks like below..
Map<String, String> data = new Map<String, String>{
            'email' => acc.Email__c,
            'displayName' => acc.Display_Name__c,
            'bioUrl' => acc.Bio_URL__c,
            'imageUrl' => acc.Image_URL__c,
            'vertical' => acc.Channel__c,
            'status' => acc.Status__c,
            'gid' => acc.Legacy_GID__c,
            'numberOfExperts' => String.valueOf(acc.Number_of_Experts__c),
            'userId' => String.valueOf(acc.Selene_ID__c),
            'socialPreference' => acc.Social_Presence__c
        };
        String jsonInput = JSON.serializePretty(data, True);

While the output that I am seeking is like..
{
  "socialPreference" : [
                    "www.facebook.com/101", 
                    "www.twitter.com/101"
                        ],
  "userId" : "123456789123",
  "numberOfExperts" : "1",
  "gid" : "210967",
  "status" : "LIVE",
  "vertical" : "SALESFORCE",
  "imageUrl" : "",
  "bioUrl" : "",
  "displayName" : "test101",
  "email" : "test101@test.com"
}
I don't know how to convert just one value (socialPresence)into an array format.
That is a LONG TEXT field in UI and will hold multiple urls separated by comma or semi-colon.

 
Hello,

I am building an approval process for a custom object and have run into a problem.
The approval process limit is 1000 records at each execution. 
While my page will send more than 1000 records for approval at a single click.
So it seems I cannot use standard approval process provided in CRM.
Does any one know a way how this limit can be bypassed or do I need to write complete custom code for approval process??

Any help is appreciated.
Thanks!
Hello Guys,

I have setup a simple SEARCH visualforce page...
I am having a hard time covering test percentage... and am stuck at 35%
Can some one guide me as to how I can improve the code coverage...

I don't think anyone needs VF page as the problem is with test class and the controller. 
 APEX CLASS :
 
public with sharing class URLMonthlySearchController {
	 
    public URL_Monthly_Activity__c usr {get; set;}
     
    public List<URL_Monthly_Activity__c> AllGIDs
    {
        get
        {
            if(con != null)
                return (List<URL_Monthly_Activity__c>)con.getRecords();
            else
                return null ;
        }
        set;
    } 
    
    //Controller
    public URLMonthlySearchController()
    {
        AllGIDs = new List<URL_Monthly_Activity__c>() ;
        usr = new URL_Monthly_Activity__c() ;
    }
    
    //Instantiate the StandardSetController
    public ApexPages.StandardSetController con{get; set;}
    
    public PageReference Search()
    {   
        if(usr.GID__c != null && usr.Month__c != null && usr.Year__c != null)
        {
            con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id ,GID__c, Month__c, Year__c,Total_Article_Creates__c, 
                                                                                Total_Compliant_Article_Creates__c,  Total_Article_Updates__c, 
                                                                                Total_Compliant_Article_Updates__c, Total_Newsletter_Creates__c, 
                                                                                Total_Compliant_Newsletter_Creates__c, GAPageviews__c, URL__c  
                                                                                FROM URL_Monthly_Activity__c 
                                                                                WHERE ( URL_Monthly_Activity__c.GID__c =: usr.GID__c AND URL_Monthly_Activity__c.Month__c =: usr.Month__c AND URL_Monthly_Activity__c.Year__c =: usr.Year__c)]));
 
            // sets the number of records in each page set
            con.setPageSize(50);
        }
        else
        {
            con = null;
        }
        return null ;
    }
    
     public PageReference Cancel()
    { 
        return new PageReference('/home/home.jsp');
    }   
        
    
    //Boolean to check if there are more records after the present displaying records
    public Boolean hasNext
    {
        get
        {
            return con.getHasNext();
        }
        set;
    }
 
    //Boolean to check if there are more records before the present displaying records
    public Boolean hasPrevious
    {
        get
        {
            return con.getHasPrevious();
        }
        set;
    }
 
    //Page number of the current displaying records
    public Integer pageNumber
    {
        get
        {
            return con.getPageNumber();
        }
        set;
    }

    //Returns the previous page of records
    public void previous()
    {
        con.previous();
    }
 
    //Returns the next page of records
    public void next()
    {
        con.next();
    }
}

TEST CLASS :
 
@isTest
public class URLMonthlySearchController_Test {
    
    public static testMethod void testPage(){
        
        PageReference pageRef = Page.URLMonthlySearch;
        Test.setCurrentPage(pageRef);
      
        //ApexPages.StandardSetController pageController = new ApexPages.StandardSetController();
        
        URLMonthlySearchController controller = new URLMonthlySearchController();
        //List<URL_Monthly_Activity__c> urlMon = controller.search();
        
        controller.search();
        
    }
}

Any help is appreciated.
Thanks! ​
Hello,
I have the below async class  and its test.
What I failing with is how to cover test percentage for Messaging.SingleEmailMessage Invocation when callout fails..
I have already gone through multiple links on stack exchange and Apex forum, tried some approaches but none worked for me.
Can some one please assist in what I may be doing wrong here.
Code coverage under SUCCESS is 78% while under FAILURE is 24%.
 
public class DeleteExpertInSelene {
	//method to be invoked by ProcessBuilder apex
    @InvocableMethod
    public static void deleteAccountInSelene(List<Id> acctIds){
        Account acc = [SELECT Selene_ID__c FROM Account WHERE Id = :acctIds[0]];   
        System.enqueueJob(new QueueableSeleneCall(acc.Selene_ID__c, acc.Id));
    }
    
    // future method to make delete experts
    @Future(callout=true)
    private static void deleteToSelene(Decimal userId, Id acctId) {				 
        List<String> EMAIL_RESULTS = new List<String>{System.Label.Email_Selene_List};
        List<String> EMAIL_RESULTS_2 = new List<String>{System.Label.Email_Selene_List_2};
        String tokenVar = '';
        tokenVar = 'Token '+GetSeleneID.getAuthorizationToken();
        HTTPRequest req = new HTTPRequest();
        req.setEndPoint('some api'+ userId);     
        req.setMethod('DELETE');
        req.setHeader('authorization',tokenVar);
        req.setHeader('Accept','application/json;charset=UTF-8');
        req.setHeader('Content-Type', 'application/json;charset=UTF-8'); 
        req.setHeader('Cache-Control', 'no-cache'); 
        req.setHeader('x-api-key', 'some key');
        req.setTimeout(120000);                                         
        HTTP http = new HTTP();
        HTTPResponse res = http.send(req);
        
        if(res.getStatusCode() != 200){
            System.debug('Failure: ' + res.getStatusCode() + ' ' + res.getStatus());
            // Send email
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(EMAIL_RESULTS);
            mail.setCcAddresses(EMAIL_RESULTS_2);
            mail.setSenderDisplayName('Salesforce Administrator');
            mail.setSubject('Delete To Selene Failed ');
            mail.setPlainTextBody('some mssg');
            Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});
        } else {
            if(res.getStatusCode() == 200){
                System.debug('Success: ' + res.getBody() + ' ' + res.getStatus());
        }
        
    }
           
 }   
    //queueable class to enque the put request
    class QueueableSeleneCall implements System.Queueable, Database.AllowsCallouts {
        private Decimal seleneId;
        private String Id;
        public QueueableSeleneCall(Decimal userId, Id acctId){             
            this.seleneId = userId;
            this.Id = acctId;
        }
        public void execute(QueueableContext context) {
            deleteToSelene(seleneId, Id);                               
        }
    }
}

Test Class...
@isTest
public class DeleteExpertInSelene_Test {
	  @testSetup static void testSetupdata(){
        //create the account record
        Account acc1 = new Account();
        acc1.Name = 'ABC Corp1';
        acc1.Email__c = 'test@testmail.com';
        acc1.Phone = '5554446767';
        acc1.Legacy_GID__c = '54321';
        acc1.Display_Name__c = 'abc1';
        acc1.Status__c = 'Live';
        acc1.Selene_ID__c = 112233445.00;
        insert acc1;
        //create the account record
        Account acc2 = new Account();
        acc2.Name = 'ABC Corp2';
        acc2.Email__c = 'testmail@test.com';
        acc2.Phone = '6665554343';
        acc2.Legacy_GID__c = '12345';
        acc2.Display_Name__c = 'abc2';
        acc2.Status__c = 'Live';
        acc2.Selene_ID__c = 112233446.00;
        insert acc2;
    
  }
  
       
  @isTest static void testPostCalloutSuccess() {
      Account acc = [Select Id, Name FROM Account WHERE Name = 'ABC Corp1' Limit 1];
      List<Id> accList = new List<Id>();
      accList.add(acc.Id);
      System.assertEquals('ABC Corp1', acc.Name);
      System.assertEquals(1,accList.size());
      // Set mock callout class 
      Test.setMock(HttpCalloutMock.class, new SeleneCalloutMockService()); 
      // This causes a fake response to be sent
      // from the class that implements HttpCalloutMock. 
      
      Test.startTest();
      DeleteExpertInSelene.deleteAccountInSelene(accList);
      //Integer invocations = Limits.getEmailInvocations();
      Test.stopTest(); 
      
      
      // Verify that the response received contains fake values        
      acc = [select Selene_ID__c from Account where id =: acc.Id];
      System.assertEquals(112233445.00,acc.Selene_ID__c);
      
    }
    
    @isTest static void testPostCalloutFailure() {
        Account acc = [Select Id, Name FROM Account WHERE Name = 'ABC Corp2' Limit 1];
        List<Id> accList = new List<Id>();
        accList.add(acc.Id);
        System.assertEquals('ABC Corp2', acc.Name);
        System.assertEquals(1,accList.size());  
        
        // Set mock callout class
        Test.setMock(HttpCalloutMock.class, new SeleneCalloutMockService()); 
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        Test.startTest();
        DeleteExpertInSelene.deleteAccountInSelene(accList);
        Integer invocations = Limits.getEmailInvocations();
        Test.stopTest();        
        // Verify that the response received contains fake values        
        acc = [select Selene_ID__c from Account where id =: acc.Id];
        System.assertEquals(112233446.00,acc.Selene_ID__c);
        System.assertEquals(1, invocations, 'An email should be sent');
    }  
    
}
Any help is appreciated.
Thanks!


Hello,
Below is my batch class to find the minimum pageview/session rate if affiliated record  matches certain criteria.

Concept is simple, get all Monthly Activities in a LIST and compare their Pageview_Rate against Minimum_Pageview_Rate.
If it is higher, then replace the Minimum with Pageview_Rate.
Minimum_Pageview_Rate is a common value for all records for that ONE MONTH and YEAR.

The batch is executing , but isn't updating anything.
Can someone point out what I amy be doing wrong here.

I apologize in advance for any basic error.
I am not very adept in writing batch jobs.

Any help is appreciated.
Thanks!
global class BatchToFindFormerAuthorRate implements Database.Batchable<sObject>, Schedulable{
    
    global final string query;
	private Date currentDate = date.today();
    
    global BatchToFindFormerAuthorRate(){
       query = 'SELECT Id,Paid_On__c,FA_Pageview_Rate__c,FA_Session_Rate__c, Minimum_Pageview_Rate__c,Minimum_Session_Rate__c, Expert_Contract__r.Status__c, Month__c, Year__c ,Pageview_Rate__c, Session_Rate__c FROM Monthly_Activity__c';  
    	
    }
               
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Monthly_Activity__c> scope){			
        List<Monthly_Activity__c> monActList = new List<Monthly_Activity__c>();
       
        for(Monthly_Activity__c c : scope){
            if(c.Expert_Contract__r.Status__c == 'Live' && c.Month__c == currentDate.month() && c.Year__c == currentDate.year()){
                if(c.Paid_On__c == 'Pageviews' && c.Minimum_Pageview_Rate__c > c.Pageview_Rate__c ){
                    c.Minimum_Pageview_Rate__c = c.Pageview_Rate__c;
                    c.FA_Pageview_Rate__c = c.Minimum_Pageview_Rate__c/2;
                    monActList.add(c);       
            	}else if(c.Paid_On__c == 'Sessions' && c.Minimum_Session_Rate__c > c.Session_Rate__c){
                    c.Minimum_Session_Rate__c = c.Session_Rate__c;
                    c.FA_Session_Rate__c = c.Session_Rate__c/2;
                    monActList.add(c);
    	}
       }         
     }
     update monActList;        
 }      
    
    global void execute(SchedulableContext SC){
        Database.executeBatch(new BatchToFindFormerAuthorRate());                  
    }
    
    global void finish(Database.BatchableContext BC){
        List<String> EMAIL_RESULTS = new List<String>{System.Label.Email_List};
             
        AsyncApexJob apexBatchResult = [
            SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
            FROM AsyncApexJob
            WHERE Id =: BC.getJobId()
        ];
    
        // Generate email body
      
    

    }
 }

 
Hello,
I have an apex callout class and a future callout method where I am passing JsonInput of Account fields.
During integration testing, it was requested that any field without any value , should be returned as ' ' <just blank> and not as "Null".
I don't think we can pass ' ' <just blank> in JSON.
But I still gave it a shot and checked blank value before creating json input...
@InvocableMethod
 public static void postAccountToSystem(List<Id> acctIds){
 Account acc = [SELECT Name,Display_Name__c,
                       Bio_URL__c,Image_URL__c
                        FROM Account WHERE Id = :acctIds[0]];  
       
        if(acc.Display_Name__c == NULL){
            acc.Display_Name__c = '';
        }
		
        if(acc.Bio_URL__c == NULL){
            acc.Bio_URL__c = '';
        }
        if(acc.Image_URL__c == NULL){
            acc.Image_URL__c = '';
        }
         
       String jsonInput = '{\n' +
            ' "displayName" : "'+acc.Display_Name__c+'",\n'+
            ' "bioUrl" : "'+acc.Bio_URL__c+'",\n'+
            ' "imageUrl" : "'+acc.Image_URL__c+'",\n'+
           System.enqueueJob(new QueueableCall(jsonInput, acc.Id));   
    }

Although the code saved, I am getting an "Internal Server Error, Status Code= 500" everytiime I lauch the callout.
Does any one have an idea how I can make the blank value as ' ' and not as "Null".
Any help is appreciated.

Thanks! 
 
Hello guys,

I have written the follwing trigger to sum two fields ..
The reason I couldn't use a WF / Process / Formula is due to the sheer size of the formula as the fields being added are themselves formula , which are also getting calculated from other fields..
So the total character size is getting exponential and its not working ..
Hence the trigger ... But the problem I am facing is that for such a small trigger , the test class is getting enornmous as the fields are formula and I cannot simply insert values to it..

Does any one know of an easier approach to writing a test class for this trigger ...
Both "Pageview Comp" and "Session Comp" are formula fields ...
trigger UpdateVariableFee on Monthly_Activity__c (before insert, before update) {
    if(trigger.isBefore){
        if(trigger.isInsert || trigger.isUpdate){
            for(Monthly_Activity__c obj :trigger.new){       
                obj.Variable_Fee_Sum__c = obj.Pageview_Comp__c + obj.Session_Comp__c;
            } 
        }        
    }
}
Any help is appreciated.
Thanks!
A
 
I have a batch job which is currently calling out to an external API for just 1 record  at a time and is getting response back for ALL reords which is over 12 MB.
Can Salesforce do something to chunk the response into smaller uints and process them correctly or does the external API needs to just send the response back for 1 record, instead of sending them all at once??

I think it should be the latter as I don't know any method to do the former.
Please provide some guidance if you happen to know.

Thanks!
Hello,
I have a batch job which runs to populate two objects.. Monthly Activity(MonAct) and URL Individual monthly Activity (URLIndMonAct)...
The problem with the response is that I am quering for MonAct records and I am getting back 5 of them . And each of those MonAct records contains with it thousands of URLIndMonAct records...

I have limited my query to just 2 records per batch but I am still getting DML Rows : 10001 error ..
If I redice the size to 1 record, the batch is running for too long...

Can any one please guide me, how can I modify my code to prevent this error and not lose any records while processing...
Any help is appreciated.

Thanks!
global class BatchToUpdateGARecords implements Database.Batchable<sObject>, Database.Stateful, Schedulable, Database.AllowsCallouts{

    private List<String> EMAIL_BATCH_RESULTS = new List<String>{System.Label.Email_List};  
    global  IndividualMonthlyGARecords.BatchResponse runningBatchResponse;
    private String query;
    private Integer queryYear;
    private Integer queryMonth;

    global BatchToUpdateGARecords(Integer year, Integer month){
        runningBatchResponse = new IndividualMonthlyGARecords.BatchResponse();

        // Validate user input, if request to run batch is not for todays date
        if(month != null && year != null && month >= 0 && month <= 12 && year > 1950){
            this.queryYear  = year;
            this.queryMonth = month;
        }
        else{
            Date yesterdaysDate = Date.today().addDays(-1);

            this.queryYear  = yesterdaysDate.year();
            this.queryMonth = yesterdaysDate.month();
        }

        this.query  = 'SELECT Id, GID__c ';
        this.query += 'FROM Monthly_Activity__c ';
        this.query += 'WHERE Year__c = ' + queryYear + ' ';
        this.query += 'AND Month__c = ' + queryMonth + ' ';
        this.query += 'AND GID__c <> null ';
        this.query += 'AND GID__c > 0 ';
        
    }

    global BatchToUpdateGARecords(){
        this(null, null);
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Monthly_Activity__c> currentBatchRecords){
	
        List<Monthly_Activity__c> MonthlyActivities = [
            SELECT Id, GID__c, Month__c, Year__c
            FROM Monthly_Activity__c 
            WHERE Year__c =: queryYear
            AND Month__c =: queryMonth
            AND GID__c IN: Pluck.decimals('GID__c', currentBatchRecords)
        ];        

        List<URL_Individual_Monthly_Activity__c> urlIndividualMonthlyActivities = [
            SELECT Id, GID__c, URL__c, Month__c, Year__c
            FROM URL_Individual_Monthly_Activity__c 
            WHERE Year__c =: queryYear
            AND Month__c =: queryMonth
            AND GID__c IN: Pluck.decimals('GID__c', currentBatchRecords)
        ];        
         
        if(MonthlyActivities.isEmpty()){
            return;
        }
    
        try{           
            IndividualMonthlyGARecords.batchHandlerToUpdateRecords(
                runningBatchResponse,
                MonthlyActivities,
                urlIndividualMonthlyActivities,
                queryYear,
                queryMonth
            );
        
       }catch(exception ex){
            system.debug('exception call :'+ ex.getMessage());
            system.debug('exception call line :'+ ex.getStackTraceString());
        }
        if(runningBatchResponse != null && !runningBatchResponse.getSuccessRecords().isEmpty()){
            List<Database.SaveResult> updateResults =
                Database.update(runningBatchResponse.getSuccessRecords(), false);

            for(Database.SaveResult updateResult : updateResults){
              if(!updateResult.isSuccess()){
                for(Database.Error err : updateResult.getErrors()){
                  runningBatchResponse.addDatabaseError(err.getMessage());
                }
              }
            }
        }

        runningBatchResponse.clearSuccessRecords();
    
        if(runningBatchResponse != null && !runningBatchResponse.getSuccessRecordsIMA().isEmpty()){

            List<Database.SaveResult> updateResults1 =
                Database.update(runningBatchResponse.getSuccessRecordsIMA(), false);

            for(Database.SaveResult updateResult1 : updateResults1){
              if(!updateResult1.isSuccess()){
                for(Database.Error err : updateResult1.getErrors()){
                  runningBatchResponse.addDatabaseError(err.getMessage());
                }
              }
            }
        }

        runningBatchResponse.clearSuccessRecords();
  
    }

    global void execute(SchedulableContext SC){
        Database.executeBatch(new BatchToUpdateGARecords(), 2);                            //Changed from 5    }
    
    global void finish(Database.BatchableContext BC){
        AsyncApexJob apexBatchResult = [
            SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
            FROM AsyncApexJob
            WHERE Id =: BC.getJobId()
        ];
    
        // Generate email body
        String emailBody = 'Apex Batch to Update PageviewSessions processed '
            + apexBatchResult.TotalJobItems + ' batches with '+ apexBatchResult.NumberOfErrors + ' failures.\n\n'
            + 'Database errors (if any): ' + JSON.serialize(runningBatchResponse.getDatabaseErrors()) + '\n';
        
        // Extract error string from batch response
        //emailBody += runningBatchResponse.generateErrorString();

        // Send email
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(EMAIL_BATCH_RESULTS);
        mail.setSenderDisplayName('About.com Experts - Batch Results');
        mail.setSubject('About.com - Batch to Update PageviewSessions - status: ' + apexBatchResult.Status);
        mail.setPlainTextBody('Batch Process has completed\n\n' + emailBody);

        Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});
    }
}

 
Hello,
I am making a callout to an external API and am getting limit exception as the response seesm to be greater than 6 MB limit.
I already knew the Governor Limits but due to certain constraints we couldn't chunk out the response from database side.
Now SFDC needs to process the reponse correctly.

Does any one have an idea how can I divide the response into groups  so as to be able to process them correctly, without getting limit exception??

The callout is being made via Batch Job.
Since I am still writing the batch job, I tested the response with Anonymous Block and the exception occurred.
Will the batch job be able to divide and handle the response ??

Any help is appreciated.
Thanks!
I have a requirement to store an AngularJS "SUM"  value being calculated directly on the VF page in an object.
I already have that value, just not sure how to being it in Salesforce..
 
​<span ng-bind="table.totalAmount"></span>
Does any one have any experience with such type of issue.

Thanks!

 
Can Streaming API be used to get data from external API into SFDC rather than send from SFDC ???
So basically Salesforce acts as a client rather than server..
Team,

I am looking for some info into sending records to an external API everytime an Account is created or updated.
It will not be a Batch Job, but instead a callout everytime account information changes.
Is it possible to do it from the salesforce layout itself,  without having to write a custom VF page for triggering the callout ?
( The reason I mentioned VF page route, because that is what I know).
I have already gone through the developer guide , so please don't reference that.
I am not looking for code , but the framework/algorithm to do it.

Any help will be appreicated.
Thanks!
 
I have written below Cross Object value transition trigger ...
When the status field on Monthly Activity is either of the 4 values, I would like to capture these 4 values from Approver_Editorial/Financial and ApproverE/F_Date ... And then assign them to 4 fields on ExpertMmonthlyAudit object...

The only connection between the 2 objects is via a lookup.

Unfortunately the fields on the 'ExpertMmonthlyAudit' are still blank.
Not sure what I am doing wrong.
Can any one care to point out.
Thanks!
trigger updateValues on Monthly_Activity__c (before insert, before update) {
    Set<Id> Ids= new Set<Id>();
    for ( Monthly_Activity__c m: Trigger.new){
        if(m.Status__c == 'Rejected by Editorial' || m.Status__c == 'Submitted to Finance' 
        || m.Status__c == 'Rejected by Finance' || m.Status__c == 'Approved'){
               Ids.add(m.Id);
         }
       }  
    List<Monthly_Activity__c> mList = new List<Monthly_Activity__c>([SELECT Id, Status__c, Approver_Editorial__c, Approver_Financial__c,ApproverE_Date__c, ApproverF_Date__c FROM Monthly_Activity__c WHERE Id in:Ids]);
    
    for(Monthly_Activity__c temp : mList){
    
    ExpertMonthlyAudit__c mVal = new ExpertMonthlyAudit__c();
    mVal.EditName__c = temp.Approver_Editorial__c;
    mVal.FinName__c = temp.Approver_Financial__c;
    mVal.EditDate__c =temp.ApproverE_Date__c;
    mVal.FinDate__c = temp.ApproverF_Date__c;
    insert mVal;
                                                                          
   }
}

 
Hello,

Does anyone has any experience implementing a Progress Bar with data information within it??

So my requirement is a progress bar which shows when the record was approved, approvers name , and then further steps..

Progress Bar >> Submitted to Govt >> Submitted by Hillary On 10th December >> Approved By Obama On 31st December  >> Submitted to WH >> Submitted By Pence On 20th February >> Rejected by Trump On 21st January ...  :)

Something like that.
Does any one know if this is possible.
And this has to be on display upon page load, and not like an On-click feature.

I know how to create VF progress bar representing percentage and status level, but I haven't ventured in displaying the actual data.
Any and every help will be appreciated.
Thanks! 
Hi ,

Can some one help me to write a trigger to prevent delete of all Account records and its supporting test class.
Doesn't matter who the user is (Sys Admin/Custom Profile/Read Only...etc), the user should not be able to delete the account record.
There cannot be any exception.

Any help is appreciate.
Thanks!
A
Hi,
Does anyone know how to build a service which allows Kafka to push data into Salesforce?
Or maybe a service where Salesforce listens to Kafka changes via api and creates a record in one or more objects?
Any help is appreciated.
Thanks!
Hello,

Disclaimer : I have read the all the documentation for sites, so please don't just post links.

I am just curious to hear from folks who have used Sites, as to the limitations surrounding it, like
  1. Can I build a site which accepts details and attachments (like a form) from site users , without the need for any additional license?
  2. Can I build workflows and approval processes around the records which were captured via sites?
  3. How many folks can access the site per month?
  4. What happens when site limits are breached?
  5. How many clicks to the site are allowed per day?
  6. How much should Aura compenents be involved in building sites or can it just be a simple VF page?
Things like that.
Any advice/information in this regards would be much appreciated.
Thanks!
I have a service inserting records and accepting EST values.
"publishedAtEt": "2019-06-13T15:00:33",
"submittedAtEt": "2019-05-01T00:03:34",
Then I have a formula field to figure out the month for "submitted at" value.
INTEGER SUB_MONTH = MONTH(DATEVALUE( Submitted_At__c ))
But upon debugging , I am finding that the SUB_MONTH value is not 5, but 4.
USER_DEBUG |DEBUG|Sub_Month 4
Has anyone ever experienced something like that?
If yes, how did you resolve.
Any help is appreciated.
Thanks!

 
All of our Visualforce pages suddenly stopped displaying all fields and values. I see no changes made to the pages, the underlying classes, the objects and fields referenced, nor to guest profile permissions.
On the Salesforce side, the only message I see is that legacy SOAP API versions were retired today, but I don't see how that comes into play here. Furthermore, they say those versions are usable until the Winter '19 release (we are on Summer '18).

Has anyone seen this before?
I am trying to send a record to an external system via Async service . Only one value within that payload needs to be an array while the remaining should be string. Does any one know how it can be done?
searlization looks like below..
Map<String, String> data = new Map<String, String>{
            'email' => acc.Email__c,
            'displayName' => acc.Display_Name__c,
            'bioUrl' => acc.Bio_URL__c,
            'imageUrl' => acc.Image_URL__c,
            'vertical' => acc.Channel__c,
            'status' => acc.Status__c,
            'gid' => acc.Legacy_GID__c,
            'numberOfExperts' => String.valueOf(acc.Number_of_Experts__c),
            'userId' => String.valueOf(acc.Selene_ID__c),
            'socialPreference' => acc.Social_Presence__c
        };
        String jsonInput = JSON.serializePretty(data, True);

While the output that I am seeking is like..
{
  "socialPreference" : [
                    "www.facebook.com/101", 
                    "www.twitter.com/101"
                        ],
  "userId" : "123456789123",
  "numberOfExperts" : "1",
  "gid" : "210967",
  "status" : "LIVE",
  "vertical" : "SALESFORCE",
  "imageUrl" : "",
  "bioUrl" : "",
  "displayName" : "test101",
  "email" : "test101@test.com"
}
I don't know how to convert just one value (socialPresence)into an array format.
That is a LONG TEXT field in UI and will hold multiple urls separated by comma or semi-colon.

 
Hello,

I am building an approval process for a custom object and have run into a problem.
The approval process limit is 1000 records at each execution. 
While my page will send more than 1000 records for approval at a single click.
So it seems I cannot use standard approval process provided in CRM.
Does any one know a way how this limit can be bypassed or do I need to write complete custom code for approval process??

Any help is appreciated.
Thanks!
Hello Guys,

I have setup a simple SEARCH visualforce page...
I am having a hard time covering test percentage... and am stuck at 35%
Can some one guide me as to how I can improve the code coverage...

I don't think anyone needs VF page as the problem is with test class and the controller. 
 APEX CLASS :
 
public with sharing class URLMonthlySearchController {
	 
    public URL_Monthly_Activity__c usr {get; set;}
     
    public List<URL_Monthly_Activity__c> AllGIDs
    {
        get
        {
            if(con != null)
                return (List<URL_Monthly_Activity__c>)con.getRecords();
            else
                return null ;
        }
        set;
    } 
    
    //Controller
    public URLMonthlySearchController()
    {
        AllGIDs = new List<URL_Monthly_Activity__c>() ;
        usr = new URL_Monthly_Activity__c() ;
    }
    
    //Instantiate the StandardSetController
    public ApexPages.StandardSetController con{get; set;}
    
    public PageReference Search()
    {   
        if(usr.GID__c != null && usr.Month__c != null && usr.Year__c != null)
        {
            con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id ,GID__c, Month__c, Year__c,Total_Article_Creates__c, 
                                                                                Total_Compliant_Article_Creates__c,  Total_Article_Updates__c, 
                                                                                Total_Compliant_Article_Updates__c, Total_Newsletter_Creates__c, 
                                                                                Total_Compliant_Newsletter_Creates__c, GAPageviews__c, URL__c  
                                                                                FROM URL_Monthly_Activity__c 
                                                                                WHERE ( URL_Monthly_Activity__c.GID__c =: usr.GID__c AND URL_Monthly_Activity__c.Month__c =: usr.Month__c AND URL_Monthly_Activity__c.Year__c =: usr.Year__c)]));
 
            // sets the number of records in each page set
            con.setPageSize(50);
        }
        else
        {
            con = null;
        }
        return null ;
    }
    
     public PageReference Cancel()
    { 
        return new PageReference('/home/home.jsp');
    }   
        
    
    //Boolean to check if there are more records after the present displaying records
    public Boolean hasNext
    {
        get
        {
            return con.getHasNext();
        }
        set;
    }
 
    //Boolean to check if there are more records before the present displaying records
    public Boolean hasPrevious
    {
        get
        {
            return con.getHasPrevious();
        }
        set;
    }
 
    //Page number of the current displaying records
    public Integer pageNumber
    {
        get
        {
            return con.getPageNumber();
        }
        set;
    }

    //Returns the previous page of records
    public void previous()
    {
        con.previous();
    }
 
    //Returns the next page of records
    public void next()
    {
        con.next();
    }
}

TEST CLASS :
 
@isTest
public class URLMonthlySearchController_Test {
    
    public static testMethod void testPage(){
        
        PageReference pageRef = Page.URLMonthlySearch;
        Test.setCurrentPage(pageRef);
      
        //ApexPages.StandardSetController pageController = new ApexPages.StandardSetController();
        
        URLMonthlySearchController controller = new URLMonthlySearchController();
        //List<URL_Monthly_Activity__c> urlMon = controller.search();
        
        controller.search();
        
    }
}

Any help is appreciated.
Thanks! ​
Hello,
I have the below async class  and its test.
What I failing with is how to cover test percentage for Messaging.SingleEmailMessage Invocation when callout fails..
I have already gone through multiple links on stack exchange and Apex forum, tried some approaches but none worked for me.
Can some one please assist in what I may be doing wrong here.
Code coverage under SUCCESS is 78% while under FAILURE is 24%.
 
public class DeleteExpertInSelene {
	//method to be invoked by ProcessBuilder apex
    @InvocableMethod
    public static void deleteAccountInSelene(List<Id> acctIds){
        Account acc = [SELECT Selene_ID__c FROM Account WHERE Id = :acctIds[0]];   
        System.enqueueJob(new QueueableSeleneCall(acc.Selene_ID__c, acc.Id));
    }
    
    // future method to make delete experts
    @Future(callout=true)
    private static void deleteToSelene(Decimal userId, Id acctId) {				 
        List<String> EMAIL_RESULTS = new List<String>{System.Label.Email_Selene_List};
        List<String> EMAIL_RESULTS_2 = new List<String>{System.Label.Email_Selene_List_2};
        String tokenVar = '';
        tokenVar = 'Token '+GetSeleneID.getAuthorizationToken();
        HTTPRequest req = new HTTPRequest();
        req.setEndPoint('some api'+ userId);     
        req.setMethod('DELETE');
        req.setHeader('authorization',tokenVar);
        req.setHeader('Accept','application/json;charset=UTF-8');
        req.setHeader('Content-Type', 'application/json;charset=UTF-8'); 
        req.setHeader('Cache-Control', 'no-cache'); 
        req.setHeader('x-api-key', 'some key');
        req.setTimeout(120000);                                         
        HTTP http = new HTTP();
        HTTPResponse res = http.send(req);
        
        if(res.getStatusCode() != 200){
            System.debug('Failure: ' + res.getStatusCode() + ' ' + res.getStatus());
            // Send email
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(EMAIL_RESULTS);
            mail.setCcAddresses(EMAIL_RESULTS_2);
            mail.setSenderDisplayName('Salesforce Administrator');
            mail.setSubject('Delete To Selene Failed ');
            mail.setPlainTextBody('some mssg');
            Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});
        } else {
            if(res.getStatusCode() == 200){
                System.debug('Success: ' + res.getBody() + ' ' + res.getStatus());
        }
        
    }
           
 }   
    //queueable class to enque the put request
    class QueueableSeleneCall implements System.Queueable, Database.AllowsCallouts {
        private Decimal seleneId;
        private String Id;
        public QueueableSeleneCall(Decimal userId, Id acctId){             
            this.seleneId = userId;
            this.Id = acctId;
        }
        public void execute(QueueableContext context) {
            deleteToSelene(seleneId, Id);                               
        }
    }
}

Test Class...
@isTest
public class DeleteExpertInSelene_Test {
	  @testSetup static void testSetupdata(){
        //create the account record
        Account acc1 = new Account();
        acc1.Name = 'ABC Corp1';
        acc1.Email__c = 'test@testmail.com';
        acc1.Phone = '5554446767';
        acc1.Legacy_GID__c = '54321';
        acc1.Display_Name__c = 'abc1';
        acc1.Status__c = 'Live';
        acc1.Selene_ID__c = 112233445.00;
        insert acc1;
        //create the account record
        Account acc2 = new Account();
        acc2.Name = 'ABC Corp2';
        acc2.Email__c = 'testmail@test.com';
        acc2.Phone = '6665554343';
        acc2.Legacy_GID__c = '12345';
        acc2.Display_Name__c = 'abc2';
        acc2.Status__c = 'Live';
        acc2.Selene_ID__c = 112233446.00;
        insert acc2;
    
  }
  
       
  @isTest static void testPostCalloutSuccess() {
      Account acc = [Select Id, Name FROM Account WHERE Name = 'ABC Corp1' Limit 1];
      List<Id> accList = new List<Id>();
      accList.add(acc.Id);
      System.assertEquals('ABC Corp1', acc.Name);
      System.assertEquals(1,accList.size());
      // Set mock callout class 
      Test.setMock(HttpCalloutMock.class, new SeleneCalloutMockService()); 
      // This causes a fake response to be sent
      // from the class that implements HttpCalloutMock. 
      
      Test.startTest();
      DeleteExpertInSelene.deleteAccountInSelene(accList);
      //Integer invocations = Limits.getEmailInvocations();
      Test.stopTest(); 
      
      
      // Verify that the response received contains fake values        
      acc = [select Selene_ID__c from Account where id =: acc.Id];
      System.assertEquals(112233445.00,acc.Selene_ID__c);
      
    }
    
    @isTest static void testPostCalloutFailure() {
        Account acc = [Select Id, Name FROM Account WHERE Name = 'ABC Corp2' Limit 1];
        List<Id> accList = new List<Id>();
        accList.add(acc.Id);
        System.assertEquals('ABC Corp2', acc.Name);
        System.assertEquals(1,accList.size());  
        
        // Set mock callout class
        Test.setMock(HttpCalloutMock.class, new SeleneCalloutMockService()); 
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        Test.startTest();
        DeleteExpertInSelene.deleteAccountInSelene(accList);
        Integer invocations = Limits.getEmailInvocations();
        Test.stopTest();        
        // Verify that the response received contains fake values        
        acc = [select Selene_ID__c from Account where id =: acc.Id];
        System.assertEquals(112233446.00,acc.Selene_ID__c);
        System.assertEquals(1, invocations, 'An email should be sent');
    }  
    
}
Any help is appreciated.
Thanks!


Hi,
Picklist value is not showing whenever i insert through data loader,Please anyone can help me
#dataManagement
#dataloader
Thanks
Did anything change in Salesforce over the weekend? Across all of our Apex Call Outs we are now getting this error:

System.CalloutException: Read timed out

Could this be associated with the new TLS requirements? Anyone else experiencing something like this? 

Thanks,
Ricky 
I am trying to insert a custom object from accounts, (in this case it is our prospects' current suppliers) into tasks.  That way, when our sales people pull up their tasks as they are making calls, they will automatically see who the current supplier is without having to look at the account.  I am new to salesforce but what I have gathered is that I need to create a trigger and use Apex?  Help!
We have encountered an issue that seems to have happened during a scheduled job but the debug logs were not running when the error occurred.  Would salesforce be able to send the logs for a certain timeframe for our environment?  Can I open a ticket to get that information?
In a visual force page, i want to create two section one for creating records for the object . As soon as I hit submit button In the second section of page record that got should get the display in a table. It should have at least 5 last record

I'd like to create a flow that our HR department can use for onboarding a new hire that creates a user account and configures settings such as assigning a managed package, setting a role, setting a profile, etc.

I haven't found a lot of information on this... is it even possible?
Hi ,

Can some one help me to write a trigger to prevent delete of all Account records and its supporting test class.
Doesn't matter who the user is (Sys Admin/Custom Profile/Read Only...etc), the user should not be able to delete the account record.
There cannot be any exception.

Any help is appreciate.
Thanks!
A