• mrferdos mrferdos
  • NEWBIE
  • -2 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
I have more than 500 records in invoice which is in related list to one account and the name of the account is "Account1"(Invoice- Account: Lookup relationship). Now Im try to insert more than 10 records into Invoice for the same account using dataloader. In that time only Im getting an error like "System.LimitException: Too many SOQL queries: 101". 
And my code is public class CommercientSF21InvoiceTriggerHandler1 {
    public static void accountUpdate(List<Invoice__c> currentRecordId){
        List<Account> accUpdate = new List<Account>();
        List<Account> accountWithoutInvoice = new List<Account>();
        Id accountId;
        for(Invoice__c acc : currentRecordId ){
            accountId = acc.Account__c;
        }
        List<Invoice__c> invoiceList = [select Id,CommercientSF21_IVM_InvoiceDate__c from Invoice__c where Account__c=: accountId];
        System.debug(invoiceList.size());
         for(Account acc : [select id,Current_Year_Revenue__c,Last_Order_Date__c,
                           Previous_Year_Revenue__c from Account where Id =:accountId]){
                               if(invoiceList.size() == 0){
                                   acc.Current_Year_Revenue__c = NULL;
                                   acc.Lifetime_Value_LTV__c = NULL;
                                   acc.Previous_Year_Revenue__c = NULL;
                                   accountWithoutInvoice.add(acc);
                               }
                           }
        map<id,account> accmap = new map<id,account>();
        accmap.putall(accountWithoutInvoice);
        if(accmap.size()>0){
            update accmap.values();
        }
        Set<Id> currentYearRecordIds = new Set<Id>();
        Set<Id> previousYearRecordIds = new Set<Id>();
        for(integer i=0; i<invoiceList.size(); i++){ 
            Datetime record = invoiceList[i].CommercientSF21_IVM_InvoiceDate__c;
            if(record != NULL){ 
                String yearoftherecord = String.valueOf(record.Year());
                Integer curentYear = Date.Today().Year();
                String currentYearInteger = String.valueOf(curentYear);
                Integer previousyear = curentYear -1;
                String previousyearInteger = String.valueOf(previousyear);
                if(currentYearInteger == yearoftherecord ){
                    currentYearRecordIds.add(invoiceList[i].Id);
                }
                else if(previousyearInteger == yearoftherecord){
                    previousYearRecordIds.add(invoiceList[i].Id);
                }
            }
        }
        List<AggregateResult> currentYearAmountList = [SELECT SUM(CommercientSF21_IVM_InvoiceAmt_c__c )tot FROM Invoice__c WHERE Id= :currentYearRecordIds];
        List<AggregateResult> previousYearAmountList = [SELECT SUM(CommercientSF21_IVM_InvoiceAmt_c__c )tot FROM Invoice__c WHERE Id= :previousYearRecordIds];
        List<AggregateResult> totalAmountList = [SELECT SUM(CommercientSF21_IVM_InvoiceAmt_c__c )tot FROM Invoice__c WHERE Account__c =: accountId ];
        System.debug(totalAmountList);
        Object sumAmountCurrentYear;
        Object sumAmountPreviousYear; 
        Object sumAmountTotalYear;
        for(AggregateResult acc : currentYearAmountList){
            sumAmountCurrentYear = acc.get('tot');  
        }
        for(AggregateResult acc : previousYearAmountList){
            sumAmountPreviousYear = acc.get('tot');  
        }
        
        for(AggregateResult acc : totalAmountList){
            sumAmountTotalYear = acc.get('tot');  
        }
        for(Account acc: [select id,Current_Year_Revenue__c,Last_Order_Date__c,
                          Previous_Year_Revenue__c from Account where Id =: accountId] ){
                              acc.Previous_Year_Revenue__c = Integer.valueOf(sumAmountPreviousYear);
                              acc.Current_Year_Revenue__c = Integer.valueOf(sumAmountCurrentYear);
                              acc.Lifetime_Value_LTV__c = Integer.valueOf(sumAmountTotalYear);
                              accUpdate.add(acc);
                          }
        map<id,account> accMapToUpdate = new map<id,account>();
        accMapToUpdate.putall(accUpdate);
        if(accMapToUpdate.size()>0){
            update accMapToUpdate.values();
        } 
    } 
}
Chat Transcript tabs  wont close for users. When i try the keyboard shortcuts like Shift + W, this "We couldn’t close your tabs. Try closing them manually." error appears. I would do that but the tabs don't have close buttons. I attempted creating a button to place on the record page that if clicked would close the focused tab but that didnt appear to work either. Any tips would be great! Thanks! 
I have successfully integrated the google api services and also i am abe to create .CSV fine in the google drive.But the data inside the CSV file is null(it must be due to incorrect or in proper body format). Please have a look at the code and tell me where to correct it.
Document doc = new Document(Name = 'documentName', Body = Blob.valueOf(csvFile),  Type = 'csv', ContentType='application/vnd.ms-excel');
Here the csvFile is string which contains the data of the CSV in proper format(including spaces and commas).I have used email and upload services to check the CSV file and recieved exactly what I wanted. So I used the following code for drive upload.
String boundary = 'SalesforceNewsTechnologyStuff';
String delimiter = '\r\n--' + boundary + '\r\n'; 
String close_delim = '\r\n--' + boundary + '--';
String bodyEncoded = EncodingUtil.base64Encode(doc.body);
String body = delimiter + 'Content-Type: application/json\r\n\r\n' + '{ "name" : "' + doc.Name + '",' + ' "mimeType" : "text/csv"}' + delimiter + 'Content-Type: text/application/vnd.ms-excel'  + '\r\n' + 'Content-Transfer-Encoding: base64\r\n' + '\r\n' + bodyEncoded + close_delim;
HttpRequest req = new HttpRequest();
req.setheader('Content-Length',String.valueOf(body.length()));
req.setheader('Content-Type','multipart/related; boundary='+boundary);
req.setMethod('POST'); 
req.setEndpoint('callout:Drive1'); 
req.setBody(body); 
Http h = new Http();
Httpresponse resp = h.send(req);
A blank csv gets created every time this code runs.Can any one suggest me how to add the data in the csv file?

 
Hi All, 

I am using Source Code Scanner for scanning my code. But it isn't identifying all the issues that come with Salesforce's security report. 

How do I identify all the issues before submitting my app again? 

Thank you. 
Hi all, 

I am on Create Object-Specific Quick Actions unit on Trailhead and somehow when I get to Test the Action in the Salesforce Mobile App, nothing happens on the app. I cannot see the Properties Custom Object even in the navigation menu. I have been following all the steps exactly as they appear on each task, one by one and I also passed the challenge. So, clearly I am doing the right thing, but it bugs me that I cannot see the results on the Mobile App.

I have tried everything and looked everywhere but it seems that my Salesforce App is not connected to Trailhead or something! I apologise in advance if I am not making any sense as I am new to Salesforce. 

I would really appreciate it if anyone have been through the same issue and found a solution or workaround. 

Many Thanks.
A
Hi,

I'm trying to complete the trailhead "" and encountering a challenge.  If anyone has any feedback for me on this, I'd appreciate very much.  

Added VerifyDate.apxc as I did with TemperatureConverter.apxc.  Added TestVerifyDate.apxc (even with VerifyDateTest.apxc) as I did with TemperatureConverterTest.apxc.  I verified that those classes exist per screenshot1 below:
User-added image

I'm supposed to be able to go to Test, select New Run, then with Select Tests pop-up, I'm supposed to see the TestVerifyDate (and/or VerifyDateTest) classes to select and run; however, I'm not seeing those test classes.  Why?  Even with "[All Namespaces]", they still don't show.  

Workaround for now is to run the test suite per instructions earlier in the trailhead.  

Reference screenshot2 below:
User-added image

Thanks in advance for your help.
Tien





 
Hi All,
As of now, Case page layout has Product Pick list, and we can select only one Product and it mainted by Pick List Values.
What I am looking is that, When we create a Case, we should able to select Multiple Products to that Case. How we can achieve this?.

Do we need to create a Junction Object between Cases and Product?.
I think Junction Object is not going to support for Product as Product Standard object is going to be Detail Side of Junction Object, which is not supported by Salesforce.

Please correct me if I am wrong.
Also, please suggest me an alternative methods.

Thanks,
Naren
  • August 14, 2019
  • Like
  • 1
Hi All,
In Salesforce Lightning, do we have any option to remove/disable the Drilldown/View report hyper link on Dashboard?.

Thanks,
Naren
Hi all,

We're thinking about activating Dev Hub in our production org, but I see that once it's been enabled, it can't be disabled. Is there any downside to enabling Dev Hub? Will we still have access to our old sandbox system? There's a lot of in-flight development in the current sandboxes and we don't want to change the way we work yet, we just want to explore Dev Hub and see it working in a practical environment.

Is there anything else we might need to bear in mind when activating Dev Hub? The documentation is a bit patchy on this subject.

Thanks!

How do I solve the error

REQUEST_LIMIT_EXCEEDED: TotalRequests Limit exceeded.

 

Riyaj

  • May 17, 2012
  • Like
  • 1

Hi,

 

I am following the book "Developement with the Force.com platform" by JasonOuelette.

When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?

 

thanks

Svidya

  • September 27, 2010
  • Like
  • 2

Problem statement:

 

When APEX inserting OpportunityShare records, you get DML Exception: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

 

Why does this happen?

 

The obvious reasons are:

 

  • OpportunityShare.OpportunityId is for an invalid Opportunity (or not an opportunity at all)
  • Running user doesn't have access to the Opportunity in OpportunityId



But if neither of these are the case...what else could it be?

 

ANSWER:

 

You can not insert OpportunityShare records for the current owner of the record.  You'll need to modify the Apex code to see if the current owner is the same as OpportunityShare.UserOrGroupId.  If it is, then don't insert.  You can still create OpportunityTeamMember records for that user but not OpportunityShare.  Who the current user is will depend if you are doing the OpportunityShare Dml statement in a before trigger, after trigger, VF controller, or API.

 

Although I haven't tested this, I presume the above applies to AccountShare and CaseShare objects as well.