Sharing Feels Good!

By David Gyenes, Director of IT

Ninox introduced a few new code functions. They are not new features, but the features can be executed by code now. This makes everything more useable. These new functions are about sharing. Yes, they care about us, so they give us the ability to share. So many people have the need to share files or share views and It used to be a pain in the neck, but now we have the power to share and revoke sharing. Let’s start with sharing files. What does the syntax look like?

shareFile(this, “My File Name.jpg”)

unshareFile(this, “My File Name.jpg”)

So, this function takes two parameters. The first parameter, as many of you probably know, is the “this” and it refers to the current record. We could replace “this” with record(‘Table Name’, record Id). The second parameter is a text value which is the name of the file. Yes, we need to know the file name. But what is the output? The output is a URL we get that we can send to someone by placing it into their browser. If we try to execute the old manual way by clicking the image option in the record and selecting share, we will see that the image is shared, and we see the same link. The unsharing function works the same way. Same syntax but it revokes the share. The other sharing is sharing a table view. This also has a familiar syntax. Let’s take a look at the options:

shareView(“Table Name”)
shareView(“Table Name”, “View Name”)
shareView(“Table Name”, {“contentType: “option”})
shareView(“Table Name”, “View Name”, {“contentType: “option”})
unshareView(“Table Name”)
unshareView(“Table Name”, “View Name”)

As you can see this function can take up to three parameters, but the second and third parameters are optional and can be used together or without the other. The first parameter is always the table name defined as text. If we use the “view” parameter that goes to the second place, this is also defined as text. The third parameter would be the option or technically the format we want to share it in. This can be PDF, HTML, CSV or JSON, in syntax written all lower case. Once a Ninox view has been shared, there may come a time when that share may need to be revoked or closed down. To “un-share” a view, simply use the unshareView() or unshareAllViews() discussed earlier when you want to restrict a view to authorized and licensed Ninox users.

So go out and share this information with everyone because, after all, sharing is caring!