I have a requirement to generate invoices(PDF Files) in my application. So i installed app exchange app "S-Docs" to get it done. But the problem is every time i need to click on the button to generate the PDF file. So i thought of automating it with out click of button. The code present in button was as below
/apex/SDOC__SDCreate1?id={!RecordId}&Object=Claim__c&doclist=Templateid
Now i have both recordid and templateid. So whenever i insert a record in Invoice object i am using a trigger to call Page Reference method of a class. Now i am struck at how to pass the above code in Page Reference method. Can anyone help me on this.
The code i tried so far is
public PageReference generate(Id cid){
PageReference pg = new PageReference('/apex/SDOC__SDCreate1?id='+cid);
pg.getParameters().put('Object', 'Claim__c');
pg.getParameters().put('doclist', 'a079000000O8IbL');
pg.setredirect(true);
return pg;
}
When i treid to print pg variable using debug statements what i look is below
pg:System.PageReference[/apex/SDOC_SDCreate1?doclist=a079000000O8IbL&id=a089000000gjZUxAAM&Object=Claim__c]
How can i correct the order of passing as i need it?