Building Links
UniFi has the ability to accept a link to open a specific transaction or to open a stored image or other document associated with that transaction. This can be use to provide drill-down type options from other software that has the ability to generate custom links or buttons. For example, if UniFi is being used to generate transactions that post to an accounting system, you may want the ability from an inquiry screen in that software to open the related transaction in UniFi or to see the electronic version of the invoice or other backing documents.
In order to be able to do this you need to be able to store the information that uniquely identifies the transaction or document in the system you are linking from. So in the case of a transaction being posted to accounting software, the transaction would need to include specific information to enable the drill-down as detailed below.
Linking to a UniFi transaction
To link to a UniFi transaction, the URL would be as follows:
https://<customer_account>.unifiplatform.com/item-editor/<module_id>/<transaction_id>/edit?from=datatable
The customer account and module id can be obtained by selecting that app from the menu on the left and then viewing the URL in the browser address bar - this gives us the first two parameters of the above URL. An example of this is:
https://demo.unifiplatform.com/module/db6bc4c576b94c84bc130ce5d8dcae54?from=sidebar
In this example, the customer account is 'demo', This will always be a fixed value for each customer. The module ID is the long string of characters between the last forward slash and the question mark, this will be different for each app you create and so if your links need to work across multiple apps this will need to be stored somewhere in the system generating the link, if not it can be a fixed value in the URL. This information is included in the JSON that UniFi generates by default, it can be found in the 'application_module_information' as the 'id'.
The transaction ID is unique to each transaction and is generated when the transaction is first created. Again this can be found in the JSON that UniFi generates as the 'id'. This will need to be read and sent to the other system as part of the data connector that sends the transaction from UniFi to the API of the other system.
With this information you are now able to construct a URL mixing fixed parts with the dynamic transaction ID using whatever method is available in the other system. The URL when clicked should open UniFi with the transaction requested.
The person using the link must be a UniFi user, if they are not already logged in when the link is followed they will first be directed to the log-in screen.
Linking to an attached document
You can link to an attached document directly without needing to open the form first if you prefer, using the same principle but with a different URL. The format of this URL is as follows:
https://<customer_account>.unifiplatform.com/permalink/file?key=<customer account>.<app_id>.<field_id>
The customer account can be obtained from the first part of the URL you use to access UniFi the same as linking to transactions above. All of the information needed to construct the key is part of the JSON that is sent, under the field ID of the UniFi field holding the attachment you require. So if I have a field called 'Scanned Invoice Attachment' with field ID 'scanned_invoice_attachment' in an app called 'Purchase Invoice' then the JSON would include something like this:
"scanned_invoice_attachment": "[\"demo/purchase_invoice/gqm4jfu1.yjp/scanned_invoice_attachment/my_document.pdf\"]"
So everything within the square brackets would need to be sent to the other system by the data connector so if could then be used in building the dynamic part of the URL (don't include the square brackets), although in practice the customer account and possibly the app ID may also be fixed value so you may chose not to send them.
Unlike the transaction link, the length of the dynamic part is variable as it incorporates the file name, so make sure the field you are sending it to in the other system is big enough.