You need to sign in to do that
Don't have an account?
Dennis H Palmer
QuoteDocumentController.generateDocument used to work... It doesn't now. Any update on how to use this APEX method?
The below code used to work. Now it doesn't. Anyone know why?
List<id> documentIds = new List<id>(); id templateId = 'template id here'; id quoteId = 'quote id here'; id jobId = SBQQ.QuoteDocumentController.generateDocument('en_US', quoteId, templateId, 'Proposal.pdf', 'PDF', documentIds); documentIds.add(quoteId); jobId = SBQQ.QuoteDocumentController.saveProposal('en_US', quoteId, templateId, 'Proposal.pdf', 'PDF', documentIds);
I've already checked everywhere for documentation on this API and there is none.
Try adding papersize parameter(Default/Legal/ Letter/ A4) after outputformat.
Best
Krish
The code posted by you to Generate Document works fine and I am able to create a document under quote. I have four templates and I want to generate the document for all four templates(4 documents) when a status changes. I have the generate document and save proposal class inside the template loop but only one document is getting saved.
Please find the handler class below.
Thanks
Thanks for reaching out! The only thing I can see here is that the documentIds List might need to be declared inside the Quote Template loop nested inside the Quote loop.
Below is the error I am getting in the Apex job for generating the second document. Not sure how to pass a different value for documentID
Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SBQQ__Key__c duplicates value on record with id: XXXXXXXXXXXXX: []
Let me know if you have any idea on this.
Thanks!
The document ids need to be empty before each generate document call. That is why I suggested to put the inside the template loop just before the call to generate document. The list should be empty for the generate document call and contain one value for the save proposal call.
The value of SBQQ__Key__c field on QuoteDocument object is assigned as Quoteid+'_1/_2/_3' based on the order of document. I guess it assigns the same value(eg: QuoteId_1) to all documents before the first job gets completed.
Thanks for the help Dennis!
Before Insert trigger
Hi Dennis,
I'm experiencing the same issue on a Org I'm working on, below the code snippet:
Both jobId return null.
CPQ version installed: 212.10
Could you please help me find out what I'm doing wrong? Thanks!
Thank you for your quick answer!
That's unfortunate... I'll see if I can obtain the result I need without Apex, I would rather resort to downgrading only if strictly necessary :/
Thanks anyway!
Regards.
Following up on this post. I was able to use the code below, adding in the paper size parameter. Both generateDocument and saveProposal both are running and I do see separate IDs being created for each method call.
The issue I am facing is: The ID that I get back from saveProposal gives me an error on the record indicating that "URL No Longer Exists". I checked permissions and everything seems in my scope. Is the record actualy being saved?
Any help here would be greatly appreciated! Thanks in advance!
John
Thank you for the quick reply! That makes so much sense!
I checked the Apex Jobs queue and it seems it is failing on the generateDocument call. Receiving "Unrecognized base64 character: {" now. Any thoughts on this?
Thanks,
John
I am using the most simple Quote Template. Removed Header, Footer and all sections.
Sarava, are you using the saveProposal method too?
Thanks for all your help everyone!
John
Thanks!
John
Thanks!
It was a template issue! I am successfully generating and saving the document. Here is my final code:
In this code segment, I receive the Job ID back. From here, I can query the AsyncApexJob object to get info about that job, but I do not see any reference to the QuoteDocument or the Document. I am missing the connection here back to the newly created record.
As you may have seen above, I am using a webservice apex class to initiate this document generation. From there, I'd like to grab the documentId so I could present the document to the user via a FileDownload link (i.e. https://c.na53.content.force.com/servlet/servlet.FileDownload?file=00Pf2000012NdfREAS).
Where is the data connection between the Job and the created record? Can't seem to find this in the docs.
Thanks!
John