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?
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.
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
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).
2. Salesforce AppExchange -- It looks like there are solutions to this that have a cost associated to them. This one for example
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:
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
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.
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!
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.
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!
Hi Nick, good luck! Let us know how you get on with this.