• Naresh Kaneriya
  • NEWBIE
  • 0 Points
  • Member since 2016

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

HI all,
I have "Save Attachment" button On VF page. As I click on "Save Attachment" button  the PDF is Save on Releted List of "Notes & Attachments".
When i Again Click on "Save Attachment" button the New PDF is Save in That Releted List. I want that When Click on Button the Old PDF shoud be Replace with New PDF And Latest PDF should Save. 

My Code

  public PageReference attachPDF() {
        
       List<Attachment>  at = new  List<Attachment> ();
       
        SaveAttachment  = True;
        PageReference pdf =  new PageReference('/apex/PriceSheetScreen'); 
       
        Blob body = pdf.getContentAsPDF();
        Attachment attach = new Attachment( parentId = oppid ,Name = 'PriceSheet.pdf', body =body, IsPrivate = false); 
        insert attach;
        SaveAttachment  = False;
        
        
        
         return null;
          }  


And VF page


<apex:commandButton value="Save Attachment" action="{!attachPDF}" rendered="{!$CurrentPage.Parameters.flatid != null && !SaveAttachment}" style="margin-right:4px;" />
 

HI all,
I have "Save Attachment" button On VF page. As I click on "Save Attachment" button  the PDF is Save on Releted List of "Notes & Attachments".
When i Again Click on "Save Attachment" button the New PDF is Save in That Releted List. I want that When Click on Button the Old PDF shoud be Replace with New PDF And Latest PDF should Save. 

My Code

  public PageReference attachPDF() {
        
       List<Attachment>  at = new  List<Attachment> ();
       
        SaveAttachment  = True;
        PageReference pdf =  new PageReference('/apex/PriceSheetScreen'); 
       
        Blob body = pdf.getContentAsPDF();
        Attachment attach = new Attachment( parentId = oppid ,Name = 'PriceSheet.pdf', body =body, IsPrivate = false); 
        insert attach;
        SaveAttachment  = False;
        
        
        
         return null;
          }  


And VF page


<apex:commandButton value="Save Attachment" action="{!attachPDF}" rendered="{!$CurrentPage.Parameters.flatid != null && !SaveAttachment}" style="margin-right:4px;" />
 

This is how I ended up with this issue

 

I am receiving IP Address in a URL.

In APEX controller, using pagereference get I extract the IPAddress from query string.

I am verifying this IP Address and passing it to Server from where request came from.

 

This is working all fine in developer edition, but when I tried to test the same in Sandbox using a URL, system threw a error and my page kept on reloading. Any help on this is appreciated.

 

Cyclical server-side forwards detected:

 

Cyclical server-side forwards detected: /apex/validateip?checkip=123.4.56.78&core.apexpages.devmode.url=1

 

 

Task->WhatId field is a reference to field pointing to either Account / Case / Opportunity / ..... Now i need to get all tasks whose WhatId is pointing to a Opportunity ,

Now the SOQL query that can be used for retrieval of same would be as follows

Option1

select Id,WhatId from Task where WhatId like '006%' - but this query returns error because like operator can be used only for string comparison and WhatId is a field of type ID

 

Option2

select Id,WhatId from Task where WhatId = '006%' - but this query returns no records as % is not treated to be wild char. Would like to know work around for getting all tasks having whatid pointing to a Opportunity ,

 

NOTE : - 006 is starting 3 chars of any opportunity sfdc ID