• Raji M
  • NEWBIE
  • 50 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 9
    Replies

Hi, 
Is it possible to lock records which are being processed by Batch?
Or Is there a way to restrict the user from edit when the records are processed through batch?

Thanks in advance 
 

 

Hi All,

Can someone tell me the different ways to stop recursive  triggers other than static variables approach. I had been using the static variables from day 1 of my coding but I heard that there are many different ways to stop it. I am not finding any articles about it. Can someone guide me in this.

Thanks in advance!

Thanks,
Raji M
Hi All,

Can anyone help me in reading JSON Structure through Apex. I need to find the value of "D".

{
    "A" : [{
        "B" : "C",
        
    },
    {
        "B" : {
            "D" : "E"
        }
    }]
}

Thanks,
Raji M
Here's the Apex notification I rec'd  today:
Developer script exception  : EventTrigger : EventTrigger: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00U1r00000xiwydEAA; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please do not schedule classes outside of the course start and end dates: [] Class.RoomBookingService.PerformFinalHourlyBookingUpdates: line 429, column 1 Class.RoomBookingService.ProcessHourlyBookings: line 282, column 1 Class.RoomBookingService.PairEventsWithRoomBookings: line 104, column 1 Class.EventTriggerHandler.BeforeUpdate: line 30, column 1 Class.TriggerDispatcher.Run: line 19, column 1 Trigger.EventTrigger: line 8, column 1
 If the amount__c > 100. Show error by validation rule. If I update the value from 90 to 120. What happens in before update trigger scenario and after update scenario. is it will show error in both scenario? I think it will show error on both scenarios 
Hi Friends,
I need help in getting record values from lead object for below class.
I am getting blank values when testing.
 
Class ::

public with sharing class helperleadTrigger {
    
    public static List<Lead> sendEmail(List<Lead> leads){
        Leads = [SELECT Id, Name, FirstName, LastName, Email, Business_Hub__c, Title__c FROM Lead WHERE Id =: recordId];
        for(Lead l : leads){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[]{'test@gmail.com'};
            mail.setToAddresses(toAddresses);
            mail.setTargetObjectId(l.Id);
            mail.setTemplateId('00X5D000000EmxQ');
            mail.saveAsActivity = false;
            
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            
            //Set email file attachments
            List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
            for (Attachment a : [select Id, Name, Body, ContentType, BodyLength from Attachment where ParentId =: l.Id]) {
             // Add to attachment file list
                Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
                efa.setFileName(a.Name);
                efa.setBody(a.Body);
                efa.setContentType(a.ContentType);
                fileAttachments.add(efa);
            }
            mail.setFileAttachments(fileAttachments);
        }
        return leads;
    }

Thanks in advance.

Hi, 
Is it possible to lock records which are being processed by Batch?
Or Is there a way to restrict the user from edit when the records are processed through batch?

Thanks in advance 
 

 

Hi All,

I want to compare createdDate with todays Date.
I have tried this one: 
 
List<contact> con = [Select Id,LastName,Owner.Email,OwnerId,CreatedDate,Email from Contact];
for(contact c : con) {
    if(c.CreatedDate == system.now()){
        system.debug('if');
    }else{
        system.debug('else');
    }
}


It is printed else .I want to get IF part.
Help to get the way...............
Thanks in Advance..............! 

Hi!

I have built a visual flow and hosted it on a public Force site (guest user is called "Teacher Profile").

The guest user has CREATE, READ and EDIT access to the custom object referred by the flow.

The guest user also has read and edit access to any field of the custom object.

When I run the flow, I keep getting the following error and I can't figure out why:

Error element Migrate_form_to_SF (FlowRecordCreate).
This error occurred when the flow tried to create records: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id.


I understand this is about permissions, but again the guest user has permissions to all the fields listed in "Migrate form to SF".

thank for your help.
Stefano
I have a need to upload binary stream PDF files to Amazon S3.  I've seen the sample code available to use the REST API with the POST operation on visualforce page, however, I need to upload the file via APEX without user involvment, as I'm retrieiving the files from another database via their SOAP API.

I'm trying to do this using the PUT operation, but I don't think I'm doing the authentication correctly as I'm getting a 403 Forbidden response.

Any ideas?
 
public void uploadPDF(String binaryPdfString, String key, String secret){
        String Date = Datetime.now().formatGMT('EEE,   dd MMM yyyy HH:mm:ss z');
        String bucketname = 'BucketName';
        String method = 'PUT';
        String filename = 'FileName';
        HttpRequest req = new HttpRequest();
        req.setMethod(method);
        req.setHeader('Host','s3-us-west-2.amazonaws.com');
        req.setEndpoint('https://s3-us-west-2.amazonaws.com' + '/'+ bucketname + '/' + filename);
        req.setHeader('Content-Length', string.valueOf(binaryPdfString.length()));
        req.setHeader('Content-Encoding', 'base64');
        req.setHeader('Content-Type', 'pdf');
        req.setHeader('Date', Date);

        //get signature string
        String stringToSign = 'PUT\n\n\n'+formattedDateString+'\n\n/'+bucketname+'/'+filename;
        String encodedStringToSign = EncodingUtil.urlEncode(stringToSign,'UTF-8');
        String signed = createSignature(encodedStringToSign,secret);
        String authHeader = 'AWS' + ' ' + key + ':' + signed;
        req.setHeader('Authorization',authHeader);
        req.setBody(binaryPdfString);
        Http http = new Http();

        try {
            //Execute web service call
            HTTPResponse res = http.send(req);
            System.debug('RESPONSE STRING: ' + res.toString());
            System.debug('RESPONSE STATUS: '+res.getStatus());
            System.debug('STATUS_CODE: '+res.getStatusCode());

        } catch(System.CalloutException e) {
            system.debug('AWS Service Callout Exception: ' + e.getMessage());
        }

}

public string createSignature(string canonicalBuffer,String secret){
        string sig;
        Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(canonicalBuffer),blob.valueof(secret));
        sig = EncodingUtil.base64Encode(mac);

        return sig;

}