• liron169
  • SMARTIE
  • 730 Points
  • Member since 2012

  • Chatter
    Feed
  • 26
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 32
    Questions
  • 231
    Replies
Hi.
I'm using function getContent(), to get blob of PDF page.

There are cases where the PDF is empty (blank page), and it's fine. The question how can I detect it.

-I cannot inspect the blob ,as the characters have no meaning....
-In the controller of the PDFpage I have such indication, but I cannot access it in the caller process.

Any suggestions?

PageReference page = new PageReference('/apex/PDFpage...');
blob bodyAttach=page.getContent();
Hi,
If I create FeedItem + Attachment and after a period I need to delete all the old FeedItem -for example, those that before 30 days.
<Note that all this is with apex code, not manually>

I understand that deleting the FeedItem is not deleting the attachment file, so I found that I can delete the attachments by querying ContentDocument object.

The problem is that I want to delete only the attachment that related to the feeds that were deleted, not all those in ContentDocument.
Assume that I can mark those attachments in some way (when creation) that will help to retrieve only them when need to delete them.

But perhaps I can avoid it? Does SF store in some way the connection between the FeedItem in its attachment?
Hi,

I have report - PDF page - that run sometimes on large amount of data.
with too much data, it failed when loading the page to the screen, so I try different approach- generating the page in background, and attach it to the chatter.
It does incrase the capacity of the report, but still in some amount of data it fails, and I can see in log Internal Salesforce.com Error.
I'm not hitting any other SF limitation (CPU close to limit, but not beyond).

The PDF (that failed) expected to be ~1.5MB, with ~800-1000 pages.
I able to generate it with ~1MB, ~600 pages.

Anyone have idea possible reason for this error?




global class AddPdfToRecord{
    webservice static void addPDF(){ 
     
       PageReference pdf = Page.TestLiron;
      
       pdf.getParameters().put('parm1','111');
       pdf.getParameters().put('parm2','222');
 
       pdf.setRedirect(true);
      
      //system.debug('URL: ' + pdf.getURL());

       Attachment attach = new Attachment();
       Blob body;
       try
       {
           body = pdf.getContentasPDF();        //here the failure

            // post to chatter
            FeedItem post = new FeedItem();
            post.ParentId = '0F9c00000008efE'; // nickforce chatter group id
            post.Body = 'Report for..';
            post.Type = 'ContentPost';
            post.ContentData = body;
            post.ContentFileName = 'FMR_TEST' + '.pdf';

            insert post;
       }
       catch(Exception e)
       {system.debug('EEEEEEEEEEEEEEEE'  + e) ;}
   }
}
Hi,
We have several objects that calculation of their sharing rules done in apex code.
This code is complex and dirty and hard to maintain. So I review it - and found option to move it into the UI - means calculate it with sharing rules base criteria.


There are 2 optional problem:

1.We might need to increase the available sharing rules criteria. Current limit is 50, and SF support already confirm that we can increase it, but the concern is if it will affect performance significantly?
(currently we will have 20 criteria, but in future it might increase to ~60)

2.Might need to use complex criteria. Would that reduce the performance significantly?
e.g.:   (6 AND ((2 AND (3 OR 4 OR 5)) OR (1 AND 3))) OR (7 AND 8)


Does someone have exprience with this and can advise?
Thanks.
Hi,
I have this excpetion.
I already read other questions in this issue and understand what does it means.

However, in my code I'm adding only 2 type of sobjects + adding them per list. means:

list<object1> l_first;
list<object2> l_second;
list<sobject> lsobject;

lsobject.addAll(list<sobject> l_first);
lsobject.addAll(list<sobject> l_second);

database.insert (lsobject, false);


So according to what I read I don't supposed to have this exception.

It happen only lately for large volumes of data.
Is it possible that due to size of data in the final list (lsobject), SF split the list to chunks and then go back and forth from l_first object to l_second?
Otherwise, I cannot figure why I'm getting this error.

And if so, the only solution is to split it into 2 seperaed lists?

thanks.
Hi,
I have page generate as PDF with huge amount of data. Due to the amount of data it sometimes fail (seems like timeout when loading the page, no excpetion on SF limitations).

I tried as solution to generate the page in memory and add as PDF attachment. Wrote small class (below) for testing and run it from the developer console.
When I run it for small data all is fine and its working.
But if I try it with huge data then, for some wired reason, I see that the page being generated over and over every minute (I see every minute call in the developer console), and add attachment per each run.

If I try it with very huge amount of the data, then also the page being generated every minute, but no pdf attachment is created (also can see internal error exception but without other information).

At first, I thought it's something in the code, but as it is working fine for small set of data, I'm thinking it's something internal for SF? Maybe someone have idea for this behavior?
+ Any other suggestions to enhance this process- to support huge data - will be welcome (I don't think it's related to crappy or un standard code, it's simply too much data, so I'm looking for general approach for this)

Thanks.

global class AddPdfToRecord{
   
    webservice static void addPDF(){
      
       pageReference pdf = Page.RepTestLiron;
      
      
       pdf.getParameters().put('cfr','test');
       pdf.getParameters().put('cto','');
       pdf.getParameters().put('del','');
       pdf.getParameters().put('efcont','A');;
       pdf.getParameters().put('hv','A');
       pdf.getParameters().put('repid','a1zD0000000L6WmIAK');
      
       system.debug('URL: ' + pdf.getURL());

       Attachment attach = new Attachment();
       Blob body;
       try
       {
           body = pdf.getContentasPDF();
       }
       catch(Exception e)
       {system.debug('EEEEEEEEEEEEEEEE'  + e) ;}
       attach.Body = body;
       attach.Name = 'FMR_TEST.pdf';
       attach.IsPrivate = false;
       attach.ParentId = '001D000000wqkSY';
           
        
        
       insert attach ;
    }
}

Hello,

 

I have list of records in page with checkbox on each (with wrapper class).

I'm trying to write with JQuery that only one record will be selected at time.

 

Can someone advise what wrong with below script?

It's seems that this script update the wrong data + changing the order in the list...

 

<script>
        var j$ = jQuery.noConflict();
        jQuery(document).ready(function() {
jQuery(".selected-checkbox").click(function() {
var checkedRow = this;
        //alert('Hello world, part 2!'+ checkedRow );
 jQuery(".selected-checkbox").each(
            function() {
                this.checked= false;
            }
        );
checkedRow.checked= true;

});
});
     
</script>

Hello,

 

Is there any way to get the first line from long text field without writing a trigger?

 

I read somewhere that formula function cannot detect break line, so maybe with workflow rule or any other solution?

Hi ,

 

I am very new to this. I need a solution and ideas regarding this issue. I will brief out clearly(I believe). I had an existing email templetae. I have got nothing to do with it but to change the header logo.

 

For this I got intial suggestion is To create a visualforce page and a controller to show the header dynamically on the email template depending on the user country code.

 

I have no way to Go. As of now my thought process is create let us say 4 different logos in static resources and create a visua force component for image with a condition of if country code is such then the image orheader should be such. And then call this vf component in  the email template.

 

I need suggestions and solution quickly please.

I'm having problem to code the test for the following trigger code that automatically generate relatedlist according to a value of a picklist. Until now it's with 75% code coverage.

 

trigger AddRelatedList on Obj1__c (after update) {
    List<Obj2__c> listRisks = new List<Obj2__c>();
    List<Obj3__c> listChecks = new List<Obj3__c>();
    
    //Assign the context before and after the change into a Map
    Map<Id, Obj1__c> newStatusMap = Trigger.newMap;
	Map<Id, Obj1__c> oldStatusMap = Trigger.oldMap;

	//Loop through the map
	for(Id itemId:newStatusMap.keySet()){
		Obj1__c myNewItem = newStatusMap.get(itemId);
		Obj1__c myOldItem = oldStatusMap.get(itemId);
		
		if (myNewItem.F_O__c <> myOldItem.F_O__c){
		    for (Obj1__c a : Trigger.new) {
		    	if(a.F_O__c == 'Firm'){        
			        Obj2__c clt = new Obj2__c(Line_Item__c = a.Id);
			        listRisks.add(clt);
			        
			        Obj3__c clt2 = new Obj3__c(Line_Item__c = a.Id);
			        listChecks.add(clt2);
		        }
		    }		   
		 }
	}
    insert listRisks;
    insert listChecks;
}

 It's with these 4 lines not tested:

 

Obj2__c clt = new Obj2__c(Line_Item__c = a.Id);
listRisks.add(clt);
			        
Obj3__c clt2 = new Obj3__c(Line_Item__c = a.Id);
listChecks.add(clt2);

 

Anyone knows how to help?