• Akshay Juwa
  • NEWBIE
  • 30 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 4
    Replies
I'm new to the salesforce. Does anybody know how to write a test class for the following?

public class JokeApiService {
    
    public static List<JokeApiService.JokeWrapper> getJoke(String type) {
        String url = System.Label.Joke_API_URL; 
        try {
            Http http = new Http();
            HttpRequest req = new HttpRequest();
            //10 is the max number of jokes that can be called at once 
            req.setEndpoint(url+type+'?type=single&safe-mode&amount=10');
            req.setMethod('GET');
            HttpResponse res = http.send(req); 
            Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
            String serializedJokes = JSON.serialize(results.get('jokes')); 
            List<JokeApiService.JokeWrapper> jokes = (List<JokeApiService.JokeWrapper>) JSON.deserialize(serializedJokes, List<JokeApiService.JokeWrapper>.class);
            return jokes;
        } catch (Exception e) {
            System.debug(e.getMessage()); 
            return null; 
        }
    }

    public class JokeWrapper { 
        public String category;
        public String type;
        public String joke;
    }
}
Hello everyone, I just need help with creating a list of shipment that is stored in shipmentList and I want to loop through the ShipmentList, update map's orderLine Key with tracking value and create a boolean value if its a reshipment.
Hello Everyone. I'm trying to create a list of shipments for a company. This apex class has a code setup in a way that the reshipment tracking number doesn't get updated over the older shipment. So what I need help is with creating a list of shipments instead of just taking the first one. And parse initialize a Map<String, String> orderLineTrackingNumberMap as well as a boolean flag to indicate if there's been a reship. As we loop thought the ShipmentList, update map's orderLineKey with tracking value (if reshipment, update the parent orderline tracking to new tracking, if this operation happens, update the flag to true.)

The following code snippet needs to be altered.

 Dom.XmlNode trackingXML = detailsXML.getChildElement('ShipmentList', null);
        System.debug('AJ1001 tracking xml:' + trackingXML);
        if(trackingXML!=null)
        {
            trackingXML = trackingXML.getChildElement('Shipment',null);
            System.debug('AJ1001 shipment xml:' + trackingXML);
            if(trackingXML!=null)
            {
                trackingXML = trackingXML.getChildElement('Containers',null);
                if(trackingXML!=null)
                {
                    trackingXML = trackingXML.getChildElement('Container',null);
                }
            }
           
        }
        if(trackingXML!=null)
        {
            detailsParsed.tracking = trackingXML.getAttributeValue('TrackingNo', null);
            System.debug('AJ1001 tracking xml:' + trackingXML);
        }  
Hey everyone! Im trying to see if you can help with update the tracking number url over the old one. All the shipment info is stored in ShipmentList/Shipment/Container. I was told to Handle a list of shipments instead of taking the first one. And I also need help with parsing, they want me to initialize a Map<String, String> orderLineTrackingNumberMap as well as a boolean flag to indicate if there's a reship, as we loop through the ShipmentList, update map's orderLine Key with tracking value (if the reshipment update the parent orderline tracking to new tracking, if this operation happens update the flag true.) Could you guys guide on what the syntax would look like for these?
Hello Everyone, I haven't really worked with creating a test class yet but I'd like to know how to write a test class for the following Apex class. If you could guide on how to write a test class that'd be awesome.

public class OptOutPreference {
    public static void OptOutPreferenceLink(){
        //Now these encryption keys are obtained via custom metadata, updated API version as well
        List<SFMC_Encrypt_Setting__mdt> encrypt_settings = SFMC_Encrypt_Setting__mdt.getAll().values();
        SFMC_Encrypt_Setting__mdt setting = encrypt_settings[0];
        String initializationvector = setting.InitVector__c;
        String base64key = setting.Base64Key__c;
        String encrypttype = setting.EncryptType__c;
        
        Blob exampleIv = Blob.valueOf(initializationvector);
        Blob key = Blob.valueOf(base64key);
        
        String bxurl = 'http://cloud.mail.buxomcosmetics.com/bx_unsubscribe?&EA=';
        String bmurl = 'http://cloud.email.bareminerals.com/bm_unsubscribe?&EA=';
        String lmurl = 'http://cloud.email.lauramercier.com/AuRevoirPage?&EA=';
        String cpburl = 'http://cloud.email.cledepeaubeauteus.com/cpb_unsubscribe?&EA=';
        String shurl = 'http://cloud.email.shiseidousa.com/shi_unsubscribe?EA=';
        String narsurl = 'http://cloud.email.narscosmetics.com/nars_unsubscribe?&EA=';
        String narscaurl = 'http://cloud.email.narscosmetics.ca/en_ca_nars_unsubscribe?&EA=';
        String shcaurl = 'http://cloud.email.shiseido.ca/en_ca_sh_unsubscribe?&EA=';
        String cpbcaurl = 'http://cloud.email.cledepeaubeaute.ca/en_ca_cpb_unsubscribe?&EA=';
        String lmcaurl = 'http://cloud.email.lauramercier.ca/en_ca_lm_unsubscribe?&EA=';
        String deurl = 'https://cloud.cheers.drunkelephant.com/unsubscribe?EA=';
        String decaurl = 'https://cloud.hello.drunkelephant.ca/unsubscribe?EA=' ;
        
        List<Account> OptOutEmail =[SELECT Id, PersonEmail, Brand__c, CreatedDate, Opt_Out_Preference__c FROM Account WHERE CreatedDate < 2022-09-15T16:00:53.000+0000 AND PersonEmail !=NULL AND Brand__c !=NULL AND Opt_Out_Preference__c = NULL];
        System.debug('AJ' + OptOutEmail);
        List<Account> UpdateAccounts = new List<Account>();
        
        for (Account a : OptOutEmail){
            Blob data = Blob.valueOf(a.PersonEmail);
            Blob encrypted = Crypto.encrypt(encrypttype, key, exampleIv, data);
            String s = EncodingUtil.urlEncode(EncodingUtil.base64Encode(encrypted),'UTF-8');
            if (a.Brand__c == 'Buxom')
            {
                a.Opt_Out_Preference__c = bxurl + s;
            }
            if (a.Brand__c == 'bareMinerals')
            {
                a.Opt_Out_Preference__c = bmurl + s;
            }
            if (a.Brand__c == 'NARS')
            {
                a.Opt_Out_Preference__c = narsurl + s;
            }
            if (a.Brand__c == 'Laura Mercier')
            {
                a.Opt_Out_Preference__c = lmurl + s;
            }
            if (a.Brand__c == 'Shiseido')
            {
                a.Opt_Out_Preference__c = shurl + s;
            }
            if (a.Brand__c == 'Cle de Peau Beaute')
            {
                a.Opt_Out_Preference__c = cpburl + s;
            }
            if (a.Brand__c == 'NARS CA')
            {
                a.Opt_Out_Preference__c = narscaurl + s;
            }
            if (a.Brand__c == 'Laura Mercier CA')
            {
                a.Opt_Out_Preference__c = lmcaurl + s;
            }
            if (a.Brand__c == 'Shiseido CA')
            {
                a.Opt_Out_Preference__c = shcaurl + s;
            }
            if (a.Brand__c == 'Cle de Peau Beaute CA')
            {
                a.Opt_Out_Preference__c = cpbcaurl + s;
            }
            if (a.Brand__c == 'Drunk Elephant')
            {
                a.Opt_Out_Preference__c = deurl + s;
            }
            if (a.Brand__c == 'Drunk Elephant CA')
            {
                a.Opt_Out_Preference__c = decaurl + s;
            }
            UpdateAccounts.add(a);
        }
        update UpdateAccounts;
    }
    
}
Hello everyone! I'm trying to create a batch apex class for the following .
SELECT Id, PersonEmail, Brand__c, CreatedDate, Opt_Out_Preference__c FROM Account WHERE CreatedDate < 2022-09-15T16:00:53.000+0000 AND PersonEmail !=NULL AND Brand__c !=NULL AND Opt_Out_Preference__c = NULL AND Brand__c != 'Fragrance'

this is my first time using it..so I'd appreciate if you could guide me what to do next.
Hello Everyone, 

I am new to salesforce developing. I'd like to ask how to iterate all the records that has been queried.

 List<Account> OptOutEmail =[SELECT Id, PersonEmail, Brand__c, CreatedDate, Opt_Out_Preference__c FROM Account WHERE CreatedDate < 2022-08-10T16:00:53.000+0000];

The recods include PersonEmail, Brand__c, CreatedDate, Opt_out_preference.
Hey everybody, I'm new to salesforce and I need help with creating this apex class with a method to gather all records based on brand, email before a certain date.

From what I know I need to query to get all the records first then iterate all the records and then update the url in each record.
My company has opt-out-preference field which generates a url for the new customer however for the older customers the opt-out-preference doesn't generate the url. So they'd like to have this working for the old customers. So my plan was to build an Apex class to do such
Hello Group,

I'm new to this but I was wondering if anybody could help me with a validation rule for the following.
  
 
FieldMinor Beneficiary
CriteriaStatus = Preparation
Minor Beneficary is not null
 Minor Beneficiary DOB is blank
 Minor Beneficiary SSN is blank
 Minor Beneficiary Address is Blank
 Age of Majority is blank
 so if these criteria are true it would diplay an error.
So I added a new person as a System admin role under a Profile BJ admin. Is it going to show that I have made changes to the BJ profile?
Whenever I run my flow, its not updating the record in the salesforce.
User-added imageUser-added imageThose are all the variables in the flow. it get no error but I can't figure out why its not storing the input.
Hello everybody, I'm trying to figure out how to lock the date field when the code used checkbox is checked and set the date based on the code used is checked. Initially I was going to approach using a flow, but team prefered to use a formula instead. I'd really appreaciate the help.
Hey everyone! Im trying to see if you can help with update the tracking number url over the old one. All the shipment info is stored in ShipmentList/Shipment/Container. I was told to Handle a list of shipments instead of taking the first one. And I also need help with parsing, they want me to initialize a Map<String, String> orderLineTrackingNumberMap as well as a boolean flag to indicate if there's a reship, as we loop through the ShipmentList, update map's orderLine Key with tracking value (if the reshipment update the parent orderline tracking to new tracking, if this operation happens update the flag true.) Could you guys guide on what the syntax would look like for these?
Hello everyone! I'm trying to create a batch apex class for the following .
SELECT Id, PersonEmail, Brand__c, CreatedDate, Opt_Out_Preference__c FROM Account WHERE CreatedDate < 2022-09-15T16:00:53.000+0000 AND PersonEmail !=NULL AND Brand__c !=NULL AND Opt_Out_Preference__c = NULL AND Brand__c != 'Fragrance'

this is my first time using it..so I'd appreciate if you could guide me what to do next.
Whenever I run my flow, its not updating the record in the salesforce.
User-added imageUser-added imageThose are all the variables in the flow. it get no error but I can't figure out why its not storing the input.
Hello everybody, I'm trying to figure out how to lock the date field when the code used checkbox is checked and set the date based on the code used is checked. Initially I was going to approach using a flow, but team prefered to use a formula instead. I'd really appreaciate the help.