• Giancarlo Bailey
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
Please suggest me the code to insert a record through aura component page and displaying the same object records in aura page
Hi,I'm newbie to lwc and I have a requirement in lwc.Below is my requirement:
1. Show top 10 Lead records (Sort by Created date) in lightning table with its
details like Name, Email id, mobile No etc…
2. On Lead Record selection open Modal/Popup show form to insert the Log a
Call record (Task) against the selected Record.
3. On insert of the record a mail should be sent to the Owner of the Lead with
the details of the Log a Call (Task) record.
4. After the mail is sent a success message with date/time should updated in
lead.
I i have completed first task fetched the lead record but unable to produced call log by selection of record.
Hi guys, I need help for a Trigger, I new in Salforce and develop but I need solve this:

"However, field in Membership Sales (Number_Of_Members__c) will require automation, because roll up summary fields cannot be created between a Contact (Member) and Account (Membership). For this field, create an Apex trigger on after insert, update (only run code for update when the Account field on the Contact is updated), and delete Contact that will set the number of Contact records on the parent Account. Create a custom number field on Account named Number_Of_Members__c, which will not appear on the Membership's page layouts. This field will be updated to the count of Contacts on the Membership"

I have this code and I have to add code for the request:
trigger MemberTrigger on Contact (before insert, after insert, after update, after delete) {
    
    if (Trigger.isInsert) {
        if (Trigger.isBefore) {
            Map<String, Communication_Preferences__c> preferenceMap = new Map<String, Communication_Preferences__c>();
            for (Contact member : Trigger.New) {
                
                if (member.Communication_Preferences__c == null) {
                    Communication_Preferences__c newPreference = new Communication_Preferences__c();
                    newPreference.Name = member.lastName;
                    preferenceMap.put(member.Id, newPreference);
                }
            }
            
            insert preferenceMap.values();
            
            for (Contact member : Trigger.new) {
                member.Communication_Preferences__c = preferenceMap.get(member.Id).Id;
            }
        }
        
        if (Trigger.isAfter) {
            List<String> accountIds = new List<String>();
            
            for (Contact member : Trigger.New) {
                if (!accountIds.contains(member.AccountId)) {
                    accountIds.add(member.AccountId);
                }
            }
            
            List<Account> accountList = [SELECT Id, First_Membership_Members__c FROM Account WHERE Id IN : accountIds];
            List<Account> updatedAccounts = new List<Account>();
            
            for (Contact member : Trigger.New) {
                for (Account accountElement : accountList) {
                    if (member.AccountId == accountElement.Id) {
                        if (accountElement.First_Membership_Members__c == null) {
                            String nameString;
                            if (member.FirstName != null) {
                                nameString = member.FirstName + ' ' + member.LastName;
                            }else {
                                nameString = member.LastName;
                            }
                            accountElement.First_Membership_Members__c += member.Id + ':' + nameString;
                        }
                        else {
                            String nameString;
                            if (member.FirstName != null) {
                                nameString = member.FirstName + ' ' + member.LastName;
                            }else {
                                nameString = member.LastName;
                            }
                            accountElement.First_Membership_Members__c += ',' + member.Id + ':' + nameString;
                        }
                        
                        updatedAccounts.add(accountElement);
                    }
                }
            }
            
            update updatedAccounts;
        }
        
    }else if (Trigger.isUpdate) {
        if (Trigger.isAfter) {
        

    


    }else if (Trigger.isDelete) {
        if (Trigger.isAfter) {
           



        }
    }
    
}

I hope you can help me.
Thanks.
I created a custom object. How do I enforce that users cannot create more than 1 record on this custom object? Validation rule, flow, trigger???
Quality education essay, how to write it, don’t lose your motivation during you are study at university

When you are student you want to show what you can do in the easiest way, because all academy papers are helpful for tour research and for passing exams in the end of semester or for the global test “For many students it".

How to make Youromena interesting for worldwide auditory, as a thesis diploma in economy, technology, psychology, literature, oveschool, diagnosis, specially the dissertation is most used when are making it for the college or for going to the professional classes, but not in short terms

As usual, everystudent has a personal life writemypaper.help (https://writemypaper.help/), for example, someone have a young kids’ home, another one have a family, for some people have a part-time job, so if you decide to manage with them, in the best way, you need to be comfortable and readable As we know, when a lot of information are tending to be reading on the web, if you have a not good knowledge it’s menace that you will have a hard time, for in this moment, somebody have a really bad Idea, or something terrible happened. This will be a discouraging forstudents and other peoples, which they cause a difficulties with their work and reproach, for example, there exists a think like a scam company, which wants to concentration just for the huge numbers of employers and promote their products for the customers of such companies. So, if You are trying to make your subject more unique and attractive, try to find the most attract to interesting in the shortest manner.

Often, students after having completed the basic requirements of the essays and began to practice in preparing and writing, They thinking that it’s not enough, after that, they have a harder exam for passed exams in the few months, But in general, When you will be become to doing your homework, it’s will be more easy, than you would first thought.

Very important to understand, that our lectures have a personal Jane in whose hand, you will receive for the reports, article, coursework and the likes of numerous others articles, It’s means, that you will be using her voice and storyline in the latest news, Sometimes it’s will be worth it. Because, in the long term, the less the quality education essay, the longer it will be, the higher the grades.

If you must to pass in your article for the popular type, it’s always called‘No plagiarism.’ Of Couse,t suits does your article have a real title, which usuallycifies to scientific director, meaning that he told about the uniqueness of your works, and henceforth it’s mean that in conclusion, yes, you have a normal book, with actual data, but in not in another way, it’s a high typical error of copying.
Why am I getting this error (error is on the bold line of code below)-- 
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

public  class S3Controller {
    
    public static void UploadDocToS3Server(string recordId)
    {
        UploadDocument(recordId);
    }
    
    @future(callout=true)
    public static void UploadDocument(string recordId)
    {
        //S3 Key 
        String key = '123'; 
        //S3 Secret Key 
        String secret = '123/123/123';
        String bucket = '123'; 
        String host = 's3-us-east-1.amazonaws.com';
        String method = 'PUT';
        ProfilityCallout service=new ProfilityCallout(key,secret,bucket,method,host);
            ProfilityCallout.UploadDocuments(recordId,key,secret,bucket,method,host);
    
    }

}

public class ProfilityCallout {
 
   
    public  string awsKey {get;set;}
    public   string awsSecret {get;set;}
    public   string bucketName {get;set;}
    public   string methodName {get;set;}
    public static  string hostName {get;set;}
    public  static string statusCode {get;set;}
    public static string bucketNameStatic {get;set;}
    public static string methodNameStatic {get;set;}
    public static string hostNameStatic {get;set;}
    
    public static string awsKeyStatic {get;set;}
    public  static string awsSecretStatic {get;set;}
    
    public  ProfilityCallout(string key, string secret, string bucket, string method, string host){
        awsKey=key;
        awsSecret=secret;
        bucketName=bucket;
        methodName=method;
        hostName=host;
        bucketNameStatic = bucket;
        methodNameStatic = method;
        hostNameStatic = host;
    }
    
    public  string ContentType(string fileType) {
        switch on fileType.toLowerCase()
        {
            when 'docx'
            {
                return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            }
            when 'csv'
            {
                return 'application/vnd.ms-excel';
            }
            when 'wav'
            { 
                return 'audio/wav';
            }
            when 'wmv'
            {
                return 'video/x-ms-wmv';
            }
            when 'mp3'
            {
                return 'audio/mpeg';
            }
            when 'mp4'
            {
                return 'video/mp4';
            }
            when 'png'
            {
                return 'image/png';
                
            }
            when 'pdf'
            {
                return 'application/pdf';
                
            }
            when else {
                return 'image/jpeg';
            }
        }
    }
    
    public  string CreateAuthHeader(String contentType,
                                   String filename, String formattedDateString,string fileExtension){
                                       string auth;
                                       String stringToSign = this.methodName+'\n\n'+contentType+'\n'+formattedDateString+'\n/'+this.bucketName+'/'+filename.toLowerCase()+ '.'+fileExtension.toLowerCase();
                                       Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(this.awsSecret));
                                       String sig = EncodingUtil.base64Encode(mac);
                                       auth = 'AWS' + ' ' + this.awsKey + ':' + sig;
                                       return auth;
                                   }
    
  //  @future(callout=true)
    public static void UploadDocuments(string recordId,string key, string secret, string bucket, string method, string host){
        
        bucketNameStatic = bucket;
        methodNameStatic = method;
        hostNameStatic = host;
        awsKeyStatic=key;
        awsSecretStatic=secret;
            
      //  if(awsSecret.isBlank(this.awsSecret) || string.isBlank(this.awsKey) || string.isBlank(this.bucketName) || string.isBlank(this.hostName))
      //  {
         //   throw new BaseException('Set AWS credential');
      //  }
        List<ContentDocumentLink> links=[SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink where LinkedEntityId=:recordId];
        Set<Id> ids=new Set<Id>();
        for(ContentDocumentLink link:links)
        {
            ids.add(link.ContentDocumentId);
        }
        List<ContentVersion> versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true];
        
        for(ContentVersion attach:versions) {
         //   try
         //   {
                //File Content
                String attachmentBody = EncodingUtil.base64Encode(attach.VersionData);
                String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
                
                String filename = attach.Title;
       //////FIX LATER         string contentType=ContentType(attach.FileExtension);
         /////       system.debug('contentType:'+contentType);
                
                string fileUrl='https://' + bucketNameStatic + '.' + hostNameStatic + '/' + filename.toLowerCase().remove(' ')+ '.'+attach.FileExtension.toLowerCase();
                HttpRequest req = new HttpRequest();
                req.setMethod(methodNameStatic);
                req.setEndpoint('callout:Seek/'+ filename.toLowerCase()+ '.'+attach.FileExtension.toLowerCase());
                req.setHeader('Host', bucketNameStatic + '.' + hostNameStatic);
                req.setHeader('Content-Length', String.valueOf(attachmentBody.length()));
                req.setHeader('Content-Encoding', 'UTF-8');
         /////       req.setHeader('Content-type', contentType);
                req.setHeader('Connection', 'keep-alive');
                req.setHeader('Date', formattedDateString);
                req.setHeader('ACL', 'public-read');
                Blob pdfBlob = EncodingUtil.base64Decode(attachmentBody);
                req.setBodyAsBlob(pdfBlob);
                   
       //////FIX LATER          req.setHeader('Authorization',CreateAuthHeader(contentType, filename, formattedDateString,attach.FileExtension));
                
                Http http = new Http();
                HTTPResponse res = http.send(req);
               statusCode = string.valueof(res.getStatusCode());
                if (res.getStatusCode() == 200 || res.getStatusCode()==201) {
                     Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                        message.setSubject('Profility S3 PUT succesful!');
                        message.setPlainTextBody('Profility S3 PUT succesful!');
                        message.setToAddresses( new String[] { '123@123.org' } );
                        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } ); 
                 
                }
            
         //   catch(Exception ex)
         else   {
                
                     Messaging.SingleEmailMessage message2 = new Messaging.SingleEmailMessage();
                        message2.setSubject('issue with Profility callout');
                        message2.setPlainTextBody('issue with Profility callout '+statusCode );
                        message2.setToAddresses( new String[] { '123@123.org' } );
                        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message2 } ); 
            //   throw new BaseException(ex);
            }
        }
    }
}
I enjoy playing at online casinos. This is quite a good way to relax, and you can also make money on these games. I advise you to look at the site https://www.betsofa.com/ Especially if you are a beginner player. 
I'm a very gambling person. But at the same time, I am profitable, which probably saves me from losing. If I see that the slot machine does not want to play today, I just go to another. Right now, I stuck on the https://betsofa-official.com. A couple of times have already managed to withdraw a decent amount.
trigger UpdateType on Account (before insert,before update,after insert) {
if(trigger.isInsert && trigger.isBefore)
{
for(Account a:trigger.new)
{
if(a.industry=='education')
{
a.addError('we dont deal with education industry');
}
}
}
if(trigger.isUpdate)
{
for(Account a:trigger.new)
{
if(a.Type=='Prospect')
{
a.Type='Other';
}
}
}
}
@isTest
public class UpdateTypeTest {
static testmethod void accUpdate()
{
   Account acc= new Account( Name='Example', Industry='Education');
    insert acc;
    acc=[select name, industry, type from account where type=:acc.Type];
    System.assertEquals('Other', acc.Type);
    update acc;
   
    
}
}

Test class for the Trigger

Here the trigger fires whenever we give the type on account as prospect it would update it to 'Other'

My test class is covering only 60% of the code , somehow it is not covering the updated part. Can someone help me out?

We have a large project coming up and require additional consultants with extensive Salesforce accumen. Looking for independent contractors in the Sacramento, CA area (prefered) or possibly the San Francisco Bay Area. 

Please let me know if you are interested, or know of relevant parties who have the above mentioned skill-set. I appreciate your help!!

Best Regards,

Chad Davies

Hi,

Can someone pls help me to derive a method to parse this linkedin education response. I want to store this data into custom sfdc object. Thanks.

{"educations": {
  "_total": 2,
  "values": [
    {
      "activities": "Debate team",
      "degree": "Bachelor of Commerce (B.Com.)",
      "endDate": {"year": 2014},
      "fieldOfStudy": "",
      "id": 219318342,
      "schoolName": "The University of Texas at Austin",
      "startDate": {"year": 2010}
    },
    {
      "endDate": {"year": 2007},
      "id": 219316871,
      "schoolName": "University of California, Los Angeles",
      "startDate": {"year": 2005}
    }
  ]
}}


The method which I developed only captures one set of education data and igonres other, so just wanted to confirm my method. Also how can I parse startDate and endDate into date field of sfdc.

public void parseEduJSON(String JSONEduStr){
        if (JSONEduStr != null){
        linkedInEducation = new List<Education__c>();   
        JSONParser parser = JSON.createParser(JSONEduStr);
      
        while (parser.nextToken() != null)
        {
            if (parser.getCurrentToken() == JSONToken.START_OBJECT)
            {
               while (parser.nextToken() !=  JSONToken.END_OBJECT)
                {
               
                    if (parser.getCurrentToken() == JSONToken.START_ARRAY)
                    {
                        Education__c ei = new Education__c();
                        while (parser.nextToken() !=  JSONToken.END_ARRAY)
                        {
                              if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'activities'))
                                {
                                    parser.nextToken() ;    
                                    ei.Activities__c = parser.getText();
                                }
                                if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'degree'))
                                {
                                    parser.nextToken()     ;
                                    ei.Degree__c = parser.getText();
                                }
                                /*if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'endDate'))
                                {
                                    parser.nextToken()     ;
                                    ei.End_Date__c = parser.getDateValue();
                                }  */
                                if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'fieldOfStudy'))
                                {
                                    parser.nextToken()     ;
                                    ei.Field_of_Study__c = parser.getText();
                                }
                                if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'id'))
                                {
                                    parser.nextToken()     ;
                                    ei.LinkedIn_Educations_ID__c = parser.getText();
                                }
                                if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'schoolName'))
                                {
                                    parser.nextToken()     ;
                                    ei.Name = parser.getText();
                                }
                                /*if((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'startDate'))
                                {
                                    parser.nextToken()     ;
                                    ei.Start_Date__c = parser.getDateValue();
                                }*/
                              
                        }
                        linkedInEducation.add(ei);
                        system.debug('>>>>>>>>>>>>>>>>final education'+linkedInEducation+'<<<<<<<<<<');
                      
                    }
                }
            }
        }
      
          if(linkedInEducation.size()>0 || linkedInEducation.isEmpty() == False){
           upsert linkedInEducation LinkedIn_Educations_ID__c;
          }
      }   
    }