cancel
Showing results for 
Search instead for 
Did you mean: 

Automation of Output SFM & "Finalize" Action

Roast Chef
Roast Chef

Automation of Output SFM & "Finalize" Action

Automation of Output SFM & "Finalize" Action


We have a business case where the following is required:

Qualifying Criteria:  If Work Order reaches Status = X, and there is no WO attachment of naming convention Y, then automatically generate Attachment via "Finalize" in Output SFM.

Question:  Is there a way to access an SVMXC Output SFM, and the Finalize/create PDF action, via code?

Message 1 of 14
13 Replies
Staff Chef
Staff Chef

Re: Automation of Output SFM & "Finalize" Action

Hi Nick Sauer​, have you looked at the Scheduled SFM functionality to schedule this SFM to run for Work Orders. You can run it as frequent as every hour and it queries and finds the Work Orders that meet your criteria and it runs the SFM for them.

I haven't tried it with output document SFMs but expect it will work.

Also consider that scheduled SFMs run on batch size 1 and process is near real time so if you have a lot of Work Orders it will take a while to process them.

Regards, Richard

~If my post was useful, please give me a thumbs up! Mark correct answers as 'solutions' so we can all find answers faster!~
Message 2 of 14
Roast Chef
Roast Chef

Re: Automation of Output SFM & "Finalize" Action

Hi Richard,

Many thanks for your reply.  I indeed have tried with scheduled SFMs, but it appears that Output SFM types are not eligible for use in this capacity.  Perhaps there is a workaround to this limitation?

Best regards, Nick

Message 3 of 14
0 Likes
Reply
Staff Chef
Staff Chef

Re: Automation of Output SFM & "Finalize" Action

Hi Nick,

1. Apex Code -- It feels like this may work for you but I havent tried using code to do this before (and am not an apex code expert).

Cory Cowgill - Achievement Unlocked: Generating a PDF in an Apex Trigger

2. Salesforce AppExchange -- It looks like there are solutions to this that have a cost associated to them. This one for example

Automatically Generate Packing Slips from Salesforce Opportunities | WebMerge

3. Visualforce -- This will allow you to render a PDF. If you can call that from within apex code and then cause it to save and associate that PDF then that gives you what you need. You can use a scheduled apex class if this approach works to query for records and process them, or use an @future method or you can have it work immediately.

A lot of IFs but i am finding some encouraging things through we searches. Try this one for a starter:

Creating Professional PDF Documents with CSS and Visualforce - developer.force.com

Regards, Richard

~If my post was useful, please give me a thumbs up! Mark correct answers as 'solutions' so we can all find answers faster!~
Message 4 of 14
Roast Chef
Roast Chef

Re: Automation of Output SFM & "Finalize" Action

Thanks Richard - great detail !

We are creating/combining and manipulating PDFs in other areas through Apex via Heroku.

I'm wondering if there is a way to access the SVMXC SFM forms (finalizing them) through Apex as opposed to creating a duplicate set of custom PDF forms to fill via Apex outside of SVMXC.

So far we've been unable to figure out how we might do this, but wanted to check with the experts before going down the fully custom path!

Best regards, Nick

Message 5 of 14
0 Likes
Reply
Staff Chef
Staff Chef

Re: Automation of Output SFM & "Finalize" Action

Hi Nick, there may be others on the community who are aware of a way round this (maybe some of the ServiceMax employees). I can't think of one at the moment and am only a customer like yourself! It may be worth you putting this in as an Idea in the Ideas Exchange​.

One suggestion that may help you if you do have to duplicate your forms in the short term. If you can find a way to format what you are doing in Apex as html (in a Visualforce page or a separated apex class) then you can use html for your Output Document for use in the ServiceMax app. If you make a change then both docs have the content coding in the same format so you should only need to change one and then paste the updated html into the other. If this is technically possible then this should help reduce change effort and cost.

Regards, Richard

~If my post was useful, please give me a thumbs up! Mark correct answers as 'solutions' so we can all find answers faster!~
Message 6 of 14
Roast Chef
Roast Chef

Re: Automation of Output SFM & "Finalize" Action

In poking around the SVMX processes a bit, it seems we can get at the underlying Doc Templates, but I cannot find a particularly straightforward way of bringing all rules and templates together for access via apex.  It seems best approach would be to create html-based templates of our own in Salesforce (copying from what we're already built in SFM designer) and call those via apex.  Unfortunately this will require that we maintain in both locations anytime html updates are required.  I will hold out hope for a bit that there is a more clever way of doing this!

Message 7 of 14
Staff Chef
Staff Chef

Re: Automation of Output SFM & "Finalize" Action

Hi Nick,

I assume that the records you have found in the SVMX processes are identifiable as Doc Templates? Could you write a Trigger on the SVMX processes to take a key value from the Doc Template (new field on the SVMX processes Object or a value at the start of your Doc Template) and to query your html templates in Salesforce (which has the same key value populated). I am not sure where would be best to store these, a new object or existing object or code etc. Then the Trigger you have written can update the Salesforce html template to keep it in step. Just a off the top of my head design, if it works it may allow you to just maintain the ServiceMax ones. When you add a new ServiceMax one then add the key value to it.

Regards, Richard

~If my post was useful, please give me a thumbs up! Mark correct answers as 'solutions' so we can all find answers faster!~
Message 8 of 14
Highlighted
Roast Chef
Roast Chef

Re: Automation of Output SFM & "Finalize" Action

Those are the ones.  I'll check internally with our smarter folks and see if we might be able to do something like this.  In meantime, it seems like allowing scheduled SFM on document output/attachment might be a good Idea, and will put up on Idea Exchange.  Thanks!

Message 9 of 14
Staff Chef
Staff Chef

Re: Automation of Output SFM & "Finalize" Action

Hi Nick, good luck! Let us know how you get on with this.

Regards, Richard

~If my post was useful, please give me a thumbs up! Mark correct answers as 'solutions' so we can all find answers faster!~
Message 10 of 14
0 Likes
Reply