• Phani Pydimarry 4
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 20
    Replies
I have an account and I have multiple child records for this Account.
I would like to create a custom field and then update 1 for the first record created and if another record is created I want a field to populate 2 on the second and so on.
I want to develop this functionality because I want to track first record, second record for our analytics.
Please let me know if this is possible
I am calling a future class where an email is sent to the customer, a checkbox is turned into TRUE to avoid duplication. The email is triggered when a subscriber's end date is 15 days before. 

Now this is a subscription renewal situation and the user subscribes and again continues the package. But when the renewal arrives before 15 days again, this checkbox is true so my logic would overlook this account. 

How can I turn this checkbox to false again  after 2 days so that this email is again triggered.?

Note this check box is not read only and I would want this to be turning to true when the next iteration of expiry comes up. 

How can I achieve this scenario?

 
Hello,

I am very new to Salesforce Development. I have the following class where I post Name and Email to a rest service. Please help me in writing a test class.
public class PD_WelcomeMaroPost {
   
    @future(callout=true)
    public static void sendEmailThroughMaro(string myInpEmail) {
        string successContacts = '';
        string failureContacts = '';
        
        List<Stripe_Subscripton__c> subsToUpdate = new List<Stripe_Subscripton__c>();
        //List<Case> newCase = new List<Case>();
        
        
        // SQL to fetch FBO who Joined Today
        list<Account> conts = new list<Account> ([SELECT Id, name, Email_FLP_com__c,
        (SELECT Id
        FROM Stripe_Subscriptons__r
        WHERE Start_Date__c= TODAY
            AND Status__c='active'
            AND Welcome_Email__C = false
        LIMIT 1)
    from account
    where ID IN (
        select Distributor__c
        from Stripe_Subscripton__c
        where Start_Date__c= TODAY
            AND Status__c='active'
            AND Welcome_Email__C = false)
    AND  Email_FLP_com__c != NULL
    LIMIT 100]);
            
		system.debug('>>>>>>>>>>' + conts);
        overallEmail myEmail = new overallEmail();
       
        for(Account c : conts){
           string resultBodyGet = '';
            myEmail.email.campaign_id = 172;
            
            myEmail.email.contact.Email = c.Email_FLP_com__c;
            myEmail.email.contact.first_name = c.name;
            
            /**MAp<String, String> tags = new Map<String, String>();
            tags.put('firstName', c.name);
            myEmail.email.tags = tags;**/
            system.debug('#### Input JSON: ' + JSON.serialize(myEmail));
            
            
            try{
                String endpoint = 'http://api.maropost.com/accounts/1173/emails/deliver.json?auth_token=j-V4sx8ueUT7eKM8us_Cz5JqXBzoRrNS3p1lEZyPUPGcwWNoVNZpKQ';
                HttpRequest req = new HttpRequest();
                req.setEndpoint(endpoint);
                req.setMethod('POST');
                req.setHeader('Content-type', 'application/json');
                req.setbody(JSON.serialize(myEmail));
                Http http = new Http();
                system.debug('Sending email');
                HTTPResponse response = http.send(req); 
                system.debug('sent email');
                 resultBodyGet = response.getBody();
                system.debug('Output response:' + resultBodyGet);
                maroResponse myMaroResponse = new maroResponse();
                myMaroResponse = (maroResponse) JSON.deserialize(resultBodyGet, maroResponse.class);
                system.debug('#### myMaroResponse: ' + myMaroResponse);
                if(myMaroResponse.message == 'Email was sent successfully')
                   successContacts = successContacts + ';' + c.Email_FLP_com__c;
                else
                    failureContacts = failureContacts + ';' + c.Email_FLP_com__c;
            }
            catch (exception e) {
                failureContacts = failureContacts + ';' + c.Email_FLP_com__c;
                system.debug('#### Exception caught: ' + e.getMessage());                
            }
            
            c.Stripe_Subscriptons__r[0].Welcome_Email__c = true;
            c.Stripe_Subscriptons__r[0].Welcome_Email_Sent_Date__c = system.today();
    		subsToUpdate.add(c.Stripe_Subscriptons__r[0]);
            
              /** Case cs = new Case();       
               cs.RecordTypeId = '012m00000008ja9';
               cs.Status = 'Welcome Email Sent';
               cs.AccountId = c.Id;
               cs.OwnerId = '00Gm000000167FL';
               cs.Subject = 'FLP360 New User';
               cs.Description = resultBodyGet;
               cs.origin = 'Email';
               cs.Reason = 'New FLP360 Subscription';
               cs.Case_Sub_Reason__c = 'Email Notification';
               newCase.add(cs);**/
       
        }
       
        Update subsToUpdate;
        //insert newCase;
       // system.debug('newCase');
       
                 
    }
    
    public class maroResponse {
        public string message {get;set;}
    }

    public class overallEmail {
        public emailJson email = new emailJson();
    }
    
    public class emailJson {
        public Integer campaign_id;
        
        public contactJson contact = new contactJson();
       //Public Map<String, String> tags;
    }
    
    public class contactJson {
        public string email;
        public string first_name;
    }
    
}

 
I have a scenario where I have two Dates on Account.
Our partners move up to a level above if they buy a product in this month. But the data coming to us shows they moved up in the next month (1st to 10th) as they are processed in this time frame.
For Example
Date1: Joining Date Say 5/12/2017 MovedupDate: Moved up date Say 4/1/2018
I would like to create a flag on Account which say if the Partner moved up to a level within the same Month or the next month 1st to 10th it would come up as 'YES' or '1'. Please help me with a solution to accomplish this. My first thoughts are Process builder.
I have an account and I have multiple child records for this Account.
I would like to create a custom field and then update 1 for the first record created and if another record is created I want a field to populate 2 on the second and so on.
I want to develop this functionality because I want to track first record, second record for our analytics.
Please let me know if this is possible
Hello,

I am very new to Salesforce Development. I have the following class where I post Name and Email to a rest service. Please help me in writing a test class.
public class PD_WelcomeMaroPost {
   
    @future(callout=true)
    public static void sendEmailThroughMaro(string myInpEmail) {
        string successContacts = '';
        string failureContacts = '';
        
        List<Stripe_Subscripton__c> subsToUpdate = new List<Stripe_Subscripton__c>();
        //List<Case> newCase = new List<Case>();
        
        
        // SQL to fetch FBO who Joined Today
        list<Account> conts = new list<Account> ([SELECT Id, name, Email_FLP_com__c,
        (SELECT Id
        FROM Stripe_Subscriptons__r
        WHERE Start_Date__c= TODAY
            AND Status__c='active'
            AND Welcome_Email__C = false
        LIMIT 1)
    from account
    where ID IN (
        select Distributor__c
        from Stripe_Subscripton__c
        where Start_Date__c= TODAY
            AND Status__c='active'
            AND Welcome_Email__C = false)
    AND  Email_FLP_com__c != NULL
    LIMIT 100]);
            
		system.debug('>>>>>>>>>>' + conts);
        overallEmail myEmail = new overallEmail();
       
        for(Account c : conts){
           string resultBodyGet = '';
            myEmail.email.campaign_id = 172;
            
            myEmail.email.contact.Email = c.Email_FLP_com__c;
            myEmail.email.contact.first_name = c.name;
            
            /**MAp<String, String> tags = new Map<String, String>();
            tags.put('firstName', c.name);
            myEmail.email.tags = tags;**/
            system.debug('#### Input JSON: ' + JSON.serialize(myEmail));
            
            
            try{
                String endpoint = 'http://api.maropost.com/accounts/1173/emails/deliver.json?auth_token=j-V4sx8ueUT7eKM8us_Cz5JqXBzoRrNS3p1lEZyPUPGcwWNoVNZpKQ';
                HttpRequest req = new HttpRequest();
                req.setEndpoint(endpoint);
                req.setMethod('POST');
                req.setHeader('Content-type', 'application/json');
                req.setbody(JSON.serialize(myEmail));
                Http http = new Http();
                system.debug('Sending email');
                HTTPResponse response = http.send(req); 
                system.debug('sent email');
                 resultBodyGet = response.getBody();
                system.debug('Output response:' + resultBodyGet);
                maroResponse myMaroResponse = new maroResponse();
                myMaroResponse = (maroResponse) JSON.deserialize(resultBodyGet, maroResponse.class);
                system.debug('#### myMaroResponse: ' + myMaroResponse);
                if(myMaroResponse.message == 'Email was sent successfully')
                   successContacts = successContacts + ';' + c.Email_FLP_com__c;
                else
                    failureContacts = failureContacts + ';' + c.Email_FLP_com__c;
            }
            catch (exception e) {
                failureContacts = failureContacts + ';' + c.Email_FLP_com__c;
                system.debug('#### Exception caught: ' + e.getMessage());                
            }
            
            c.Stripe_Subscriptons__r[0].Welcome_Email__c = true;
            c.Stripe_Subscriptons__r[0].Welcome_Email_Sent_Date__c = system.today();
    		subsToUpdate.add(c.Stripe_Subscriptons__r[0]);
            
              /** Case cs = new Case();       
               cs.RecordTypeId = '012m00000008ja9';
               cs.Status = 'Welcome Email Sent';
               cs.AccountId = c.Id;
               cs.OwnerId = '00Gm000000167FL';
               cs.Subject = 'FLP360 New User';
               cs.Description = resultBodyGet;
               cs.origin = 'Email';
               cs.Reason = 'New FLP360 Subscription';
               cs.Case_Sub_Reason__c = 'Email Notification';
               newCase.add(cs);**/
       
        }
       
        Update subsToUpdate;
        //insert newCase;
       // system.debug('newCase');
       
                 
    }
    
    public class maroResponse {
        public string message {get;set;}
    }

    public class overallEmail {
        public emailJson email = new emailJson();
    }
    
    public class emailJson {
        public Integer campaign_id;
        
        public contactJson contact = new contactJson();
       //Public Map<String, String> tags;
    }
    
    public class contactJson {
        public string email;
        public string first_name;
    }
    
}

 
I have a scenario where I have two Dates on Account.
Our partners move up to a level above if they buy a product in this month. But the data coming to us shows they moved up in the next month (1st to 10th) as they are processed in this time frame.
For Example
Date1: Joining Date Say 5/12/2017 MovedupDate: Moved up date Say 4/1/2018
I would like to create a flag on Account which say if the Partner moved up to a level within the same Month or the next month 1st to 10th it would come up as 'YES' or '1'. Please help me with a solution to accomplish this. My first thoughts are Process builder.