Help with Form Category

Tagged: 

Viewing 11 reply threads
  • Author
    Posts
  • May 4, 2021 at 4:08 AM #44288

    Theo Theodosiou
    Participant

    I have a requirement for which I plan to write a form level script. It is my first Tap Forms script although I have used Javascript extensively in the past.
    My project requires that the script process multiple records from different forms within a document.
    However, I have encountered a problem which I cannot see a simple solution to.

    To explain; I have created a document that contains three categories. Within each category I have created forms where the name is the same in each category. I then have a form which I have created to hold the script that I can run once to process content in each of the forms for each category.
    An example the Hierarchy would be:

    Document:–Music
    Category:—-Classical
    Form:———-Artists
    Form:———-Titles
    Category:—-Classical
    Form:———-Artists
    Form:———-Titles
    Category:—-Uncategorized
    Form:———-Common script container.

    I have written a simple ‘hello world’ form level script that I have placed in the ‘Common script container’. This script iterates over each form in the document and displays the form name with a list of its fields.

    My problem is that I can’t find a way of differentiating the category when I list off the form names. I realise that I could create my own Category field but it seems that there should be a way of retrieving the category for the form via a function call but I just can’t seem to find anything in the documentation I have seen. I guess I could hard code the form Id to reference existing forms but how can I create a form in a specific Category using the ‘create New Form Named’ function.

    Am I missing something?

    May 7, 2021 at 12:19 PM #44309

    Daniel Leu
    Participant

    Reading the description for Categories, it looks to me that this is just a feature to better visualize forms and it is not a hierarchical component. Specially for your case, it would be helpful to have something like form.category to check which category the form belongs to. There is currently no API to support categories. Maybe something @brendan might in the future.

    Instead of using the formId, you might just use a custom field where you store the category. If it is just for a few forms, that’s not a lot of work and you can hide the field in order not the clutter the UI.

    May 8, 2021 at 4:43 AM #44327

    Theo Theodosiou
    Participant

    Thanks Daniel. Please excuse me if this reply appears more than once but my last attempt seems to have disappeared into the ether.

    I have indeed thought about a custom field but this would be at record level which would be overkill I think. Also I don’t believe it will help when creating records. I agree that a forms.category approach would be a good option.

    The whole story is that I am writing a script that calls a REST service I have written on a windows machine to ask for updates. (I no longer have my Macbook). When the script receives notification of a new record it will know to which Category and Form the record needs to be written. So I need a way of saying; get me the Id of form ‘Artists’ in category ‘Classical’. I think I will need to create a reference form in the Uncategorized section (which I am using to hold common code) and create a field for each of the Forms that I need to reference which can hold its internal unique Id. I will then use this to target the form when I add a record.

    I was hoping to avoid hardcoding these and just feel that being able to reference a form in an abstract manner would be more elegant.

    I have also noticed that hidden fields are still visible in the display when forms are referenced via a ‘Link to Form’ join. This is already messy as I currently have hidden key fields that clutter the display so I would like to keep these to a minimum.

    However, your comments are appreciated and confirm my understanding. I was hoping I had missed a trick.

    May 8, 2021 at 12:12 PM #44329

    Daniel Leu
    Participant

    Sorry, I don’t have a trick up my sleeve. The idea with a reference form might be the best workaround. I would write a script function to fetch the formID. This way, if @brendan adds something like form.catogory, you just can update that function and everything else in your code continuous to work. But here I’m just stating the obvious ;-)

    I have also noticed that hidden fields are still visible in the display when forms are referenced via a ‘Link to Form’ join. This is already messy as I currently have hidden key fields that clutter the display so I would like to keep these to a minimum.

    On the desktop you can select which fields are shown in the table by clicking on the icon at the top-left of the table. I’d assume that there is a similar setting on mobile.

    May 8, 2021 at 2:19 PM #44330

    Sam Moffatt
    Participant

    If you’re using the iOS multicolumn setup then you can select the fields to display via the “View Settings” menu to control the fields that show up there. The multicolumn list views have independent visibility toggles to the default layout.

    May 9, 2021 at 12:58 AM #44332

    Theo Theodosiou
    Participant

    Thanks guys. Yes, I have tried setting the field option to hidden for these fields in customize form, and also in the view setting for the multi-column layout. In both cases the fields are hidden when I select the form itself, but when it is displayed as a linked form the fields show in the list.

    So as an example if I select the Albums form for say Classical, the fields are hidden in both the list view and multi-column display view, whichever I choose. However, when I select an artist and the form links the joined rows from the associated albums the columns in the album list are not hidden.

    It’s a shame because I actually have a third form in each classification called Tracks which is linked to Albums. So I can select an artist, then from the linked album list I can select a specific album and end with a track list. Sweet. It is just a shame that the albums and tracks show the hidden key fields which I used to link them.

    I should add that I realise that this last issue is off topic and not really a script issue but I guess this is an area when it would be nice to be able to have an associated script to allow dynamic tailoring of views but I realise this is a big ask.

    May 9, 2021 at 10:45 PM #44340

    Sam Moffatt
    Participant

    Would you be able to share a screen shot of what you’re seeing because I think I’m a little lost.

    One thing to note is that the view settings for link to form fields can be different to the normal view settings for that form though I’m not 100% sure that’s what you’re seeing so if you haven’t already, hit view settings on the link to form list and make sure that field list has what you expect in it. It should be hidden on the record detail view when you get there, regardless of how you get to that view but the multicolumn list view screens can have different fields than the default form would have. The only other thing I can think of is that the hidden field is at the top of your list and is some how being rendered by the single column list view settings but I couldn’t replicate that on my own iPad for testing.

    Some folk have used text fields and scripts to build some pretty interesting report style interfaces, the Markdown stuff allows for some of that but it’s a limited form of Markdown to work with the printing system. It’s not the greatest system but it does provide a mechanism for building some sort of a structured report at least.

    May 10, 2021 at 12:01 PM #44343

    Theo Theodosiou
    Participant

    This is a simplified summary of the group categorised as ‘Classical’ as I have set it up on my iPhone

    Form Albums contains these fields (and a few more) in this order:
    – Title, text field to hold the album title
    – Year, text field
    – Title Id, a number field which is the unique identifier for this record. In the field options I have set ‘Hide Field’ to on
    – Artists Id, a number field containing the unique key of the parent. In the field options I have set ‘Hide Field’ to on
    – Genre, a text
    – Source, a text field

    Form Artists has 3 fields:
    – Artists, a text field that speaks for itself
    – Artists Id, a number field which is the unique identifier for this record. In the field options I have set ‘Hide Field’ to on
    – Albums, defined as Link to Form for Albums. In the field options I have selected ‘Join’ and under join setting I have selected ‘Artist Id’ as the linked field against both forms

    Thus on selecting an Artist it will also display all albums that have the same Parent

    In the View Settings for the Albums Form for the Multi-Column view I have unset the ‘Display Fields’ toggle for Title Id and Artists Id so as you suggest they will be hidden.

    I attach three screen shots.

    1 This displays an entry using list mode in the Albums Form. Note that both Title Id and Artist Id are hidden from view.
    2 This displays the same title in Multi-Column mode. Note that again both Title Id and Artist Id are hidden from view
    3 This is the same album title when it is displayed as a linked form record. As you can see in this display both the hidden fields are now visible I can see no way of hiding them

    I have copied the document to my iPad and I get exactly the same results

    Attachments:
    You must be logged in to view attached files.
    May 10, 2021 at 11:38 PM #44352

    Sam Moffatt
    Participant

    Ok, so it looks like the link to form join type on iPad doesn’t have a way of restricting the field list on device near as I can find. This might not help but you can change it on a Mac and through sync (CouchDB in my case), it replicated to my iPad. That seems like it might not be feasible right now but I think that’s your best bet if you can get access to another Mac temporarily. Perhaps the keymaster will chime in with a work around but I’m stumped on this one without sync’ing from a Mac.

    May 11, 2021 at 1:53 AM #44354

    Theo Theodosiou
    Participant

    Thanks Sam

    Sounds like the underlying database has the capability in iOS to register the hidden fields but the UI doesn’t provide a means of doing so for the linked form display. Maybe an update for the future but looks like I will have to live with it for now. At least I can reorder the fields such that they appear at the tail end of the column list.

    Appreciate your feedback though.

    May 11, 2021 at 10:20 PM #44366

    Brendan
    Keymaster

    Yes, that’s right. Sorry about that. I never got around to adding the ability to choose what fields to display on a Link to Form field on the iOS version like you can on the Mac version.

    May 13, 2021 at 12:47 AM #44375

    Sam Moffatt
    Participant

    There is a UI but it’s not accessible when the records are displayed inline in the table. If it’s rendered as a subview where you have to tap into it then you can configure that one to display as a table and control the fields on it but when it’s inline in the record itself that I can’t figure out a way to edit it. It seems to be the Link from Form that I run into this behaviour because most of my Link to Form fields render via the subview.

    Also found a bug where on iOS you can duplicate a link from form field which creates an invalid link from form field.

    May 13, 2021 at 2:52 AM #44378

    Theo Theodosiou
    Participant

    I think if the linked form inherited the settings from the Multi-Column view setup that would be useful. Although greater flexibility in the iOS version would be nice. Serves me right for having given up my Macbook.

    As I have implemented my workaround for my initial issue I can at least continue on with my project.

Viewing 11 reply threads

You must be logged in to reply to this topic.