You are viewing limited content. For full access, please sign in.

Question

Question

Need help to use an API please!

asked on October 29, 2018

Hi everyone.

I am trying to create an HTML link that will send out in the body of an email along with a quote to the customer. The email is sent via Workflow.

My goal is: Email a customer a quote (which will be attached in the form of a PDF), and within the body (of the email, not on the quote) I want to embed this link, or button - doesn't matter.

It must say "Accept" - "Reject". If the client receiving my quote clicks accept, I want to automatically pull the response when clicking in to Workflow, and accept their current outstanding Laserfiche Forms task.

This is extra functionality on top of my current system that is up and running. We want to head to automation as far as possible.

There are millions of guides that I have been staring at for hours today about nodejs this and express that and npm - and its all just too much for a simple goal like mine.

I eventually discovered this PDF laying around in the Workflow install files "Getting started with the Workflow SDK (C#)" and I think I am taking this problem on wrong.

Can anyone help me with this?

Thanks in advance!

0 0

Answer

SELECTED ANSWER
replied on October 29, 2018

I would suggest you check out this whitepaper from LF.

It could help you build a webService that would be listening for the button response from the customer

https://support.laserfiche.com/resources/2732/workflow-9-0-consuming-the-workflow-web-service

Your Buttons would point to the webservice and you would include the parameters for the Quote # and the Action

You do not need the SDK with this

1 0

Replies

replied on July 12, 2019 Show version history

From what I gather about your desire for simplicity (1. no desire to spin up a REST endpoint, and 2. no desire to work with the LF sdk), I would tackle the problem like this... 

1. Create a LF form with two text fields

  • one field will be for the answer ('yes' or 'no'), give it a [css] class of 'answer'
  • one field will be to uniquely identify the quote, give it a class 'qid'

 

2. Add some JS that will run when the page loads, and will...

   a. pull the query string parameter values from the URL

   b. place the values in the proper fields

   c. submit the form.

 

$(document).ready(function() {
    function extractParam(qsParam) {
       // if you DO NOT need to support IE, it's just...
       // `return new URLSearchParams(window.location.search).get(qsParam);`
       // but if you DO need to support IE it becomes more complicated 
       // since IE doesn't support the URLSearchParams api.
       // I would refer you to this for more info on extract qs params:
       // https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
       // Below is one implementation that I chose solely for brevity of this answer
       // (the split technique is more efficient but also more verbose, 
       //  it's what I would actually use if I were doing this myself)

       return 
           RegExp('[?&]' + qsParam + '=([^&]*)').exec(window.location.search) &&
           decodeURIComponent(match[1].replace(/\+/g, ' '));
    } 

    $('.answer').val(extractParam('a'));
    $('.qid').val(extractParam('qid'));
    $('form').submit();
});

3. Embed two links in the email with the following format:

https://<domain>/<path>?a=<answer>&qid=<quoteID>

where...

   <path> is the path to the new form

   <answer> would be '1' for the 'yes' link, and '0' for the 'no' link. 

   <quoteID> is the ID that uniquely identifies the quote

 

That should do the trick, but I am new to LF, so I don't know for sure.  You can additionally add styles for those classes (or the entire form) that will hide them from the user, as the user really won't need to interact with them.  Maybe just a visible label that says "Thank you" or whatever.  Perhaps an additional line of JS to close the browser window after submission, for a nicer user experience. 

------------------------------------------

UPDATE: 

1. To make this cross browser compatible, you may need to perform the `$('form').submit()` after a timeout, in order to allow the inputs to actually be populated before the submit is triggered...

 

setTimeout(function() { $('form').submit(); });

2. I would strongly recommend using a newly generated GUID as the "qid" value, and then [as the first step of your workflow] verify that the GUID matches one you have allocated, and tie that back to your actual quote.  You would want to then invalidate the GUID, so it can't be used again.  This will help prevent anyone that has or guesses the URL for the form from abusing the system.

 

3. The form would have to be a public or anonymous form, so your client doesn't need to be authenticated in LF.

1 0
replied on July 15, 2019

Thank you, that is quite the comprehensive reply.

I sincerely appreciate your input.

I am working on integrating Xero with Laserfiche right now, but when I go live with that, I'll most definitely spend some time on your reply.

You make it seem simple and I understand what you are explaining, I got stuck at the whole part where I return a response from a customer outside of my organization into my Laserfiche environment.

Currently having some issues with Xero too, but I should figure things out in due time.

Thanks again!

0 0
replied on July 17, 2019

You are welcome.  If you take this route please let me know if you run into any issues.  I have run this by the LF experts where I work, and they concur that it should work.  There will be two-fold scalability issues with this approach, and it should be used sparingly.  1. development/maintenance cost 2. amount of transactions that can be processed in this manner is a fraction (on the order of 1%) of what could be processed using the SDK to talk to the WF engine directly.

0 0
replied on October 29, 2018

Thanks Steve.

I also checked out https://answers.laserfiche.com/questions/70701/REST-API--Workflow-Web-Service

After I sort of started understanding the magnitude of what I am trying to achieve I have stopped working on it for now. I think this is way above my capabilities currently.

Appreciate your help and input regardless.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.