Error using Save As PDF during a workflow

  • 15 June 2017
  • 5 replies
  • 13 views

I'm trying to create a PDF snapshot in the middle of a workflow (at a midpoint user approval task) rather than the beginning. I'm following the steps in this article: https://help.k2.com/kb001394

 

All the examples I've found, including this article, seem to assume the Save As PDF is run before the workflow starts. I'm wondering if this is part of my problem. I'm saving the PDF reference as a Form Parameter during a User Task, using the After the Workflow action was submitted event in the Form Rules, Workflow Task state. I execute the Save As PDF control's Save PDF method, then transfer data with the control feeding a Form Parameter called PDF ID. This Parameter is linked to a Data Field in the workflow called PDF ID. But best I can tell this workflow data field always contains "0", it doesn't seem to be getting updated. Will the workflow pick up a change in the Form Parameter within that linked Data Field in the middle of a workflow, or does this only work if the Parameter is set before the workflow starts?

 

The PDF is getting created, I can list that SO and see the PDF, I'm just having trouble grabbing the ID as a reference and passing it in the workflow. Subsequently if I try to attach the File to a Send Email event, the workflow generates an error and halts.

 

Rule:

 11026i9B4A981D3BD2E08E.png

 

I'm just sort of at a loss at this point, I can't think of anything else to try here (and I've spent many hours trying different things). Any help would be appreciated.

 

Thanks,

Gerry

 


5 replies

Userlevel 5
Badge +16

Hi Gerry,


 


It sound like you're transferring the control before the PDF gets created, that's why the ID is always 0


 


Could you try to add the following rule:


 



 


So instead of transferring data after 'Save as PDF' action, this rule will wait until the save is completed and the ID should not be blank or 0.


The data field in the process will not be automatically updated if you're saving the PDF at a later stage so you will need to update it when the user actions the task or save the PDF ID in a smartobject then in the workflow you can call it.


 


 


hope that helps and I understood your requirement.

Thanks Mustafa. I thought the waiting for completion only applied to the Async version, so I hadn't tried that.

 

I implemented that rule, but still couldn't figure out how to get the Form Parameter to update the Workflow Data Field, so I switched to your idea of updating a SmartObject. But I was still getting the same workflow errors, until finally just now I figured out that the workflow is continuing to the next step before that rule has a chance to update the SO. I finally figured this out by sending myself emails using the Send Email function along the workflow, and putting the PDF ID field from the SO in the email. The email right after the step where I snap the PDF, save the value to the SO, etc. I get a return value of 0. But I can look a the list view of the SO and see the correct PDF ID, so I know it's there. So I put another Send Email step after another user task down the line, just to delay the email function, and after that user task the email is sent with the correct PDF ID.

 

So somehow I need to keep the workflow from moving on until after the Save As PDF creates the PDF, and the rule that waits for that completion gets a chance to run (which now instead of Transfer Data I'm just using a SO Save method). I don't see any delay function available, but I've just started looking.

 

I feel like I must be doing something wrong, otherwise this would be a common problem for lots of people, but I don't see other people complaining about this issue.

 

I appreciate the help. I'll keep working on this, and if you have any pointers I'd be happy to hear them.

 

Gerry

I should re-iterate that I'm doing this Save As PDF in a rule "After the Workflow action was submitted". Maybe this is the wrong way to go about this.

 

Basically I'm setting a user task for someone to approve a form someone else entered. So the form is initially submitted, it's presented to an approver. That approver can modify the data as needed, then approve it using the Workflow Task view that appears with the task. So in my "After the Workflow action was submitted" I'm saving all the changes to the 3 views on the forms (1 item, 2 list views), and if it's that particular approver I'm doing Save as PDF to send a snapshot of that to someone else down the line.

 

I'm not sure how else to process changes by the approver, and get the snapshot after all those changes are done, without doing it in that "After Workflow action submitted" rule. I'd hate for them to have to click a button on the form to do all this saving, then still have to select Approve and click Submit on the Workflow Task view.

 

It looks like one of my replies disappeared, I'll try to restate it - what I think is happening now is I'm now saving the PDF ID pointer to a SO, but doing that in "After the Workflow action was submitted". This is a User Task where they're reviewing, possibly updating fields, then approving the form. I'm trying to take a snapshot of that, then immediately email the PDF to another user. But the email task, next in the workflow, I think is executing before the SO gets updated. I tried putting the text of the PDF ID pointer in the email body, and it's still coming up zero. But I put another email task after another approval User Task down the line, and that one has the proper ID.

 

Is there a Delay or Wait function I can put in the workflow to say wait 10 seconds after the User Task before it tries to execute the Email Action? I can't seem to find one.

 

Edit - I may also switch to the Convert to PDF workflow function, try to do the whole thing in the workflow. That function seems a lot more convoluted, but I think it will be smart enough to wait for completion before it executes and returns the pointer. I just can't figure out why I can't figure this out 🙂 Seems like it should be easier than this.

 

Thanks,

Gerry

FYI, I got this working using the PDF Converter inside the workflow. That seems to work fine, so I'm giving up on doing this within the form. Just can't seem to make it work that way, but this is fine.

Reply