Marking a record as a favourite

Tagged: ,

Viewing 9 reply threads
  • Author
    Posts
  • September 1, 2020 at 1:28 PM #41812

    Martin Kendall
    Participant

    Hi,

    Is it possible to set a record as a favourite using JavaScript?

    Loving the scripting features of TapForms, and this would be the icing on the cake.

    Thanks

    Martin

    September 2, 2020 at 12:23 AM #41817

    Brendan
    Keymaster

    Hi Martin,

    Not at the moment. I haven’t exposed that property to JavaScript yet.

    However, the next update will have it.

    But right now the property is called isFavourite as I’m Canadian and use Canadian spelling for things when I program. But I may write a cover method for it to make it more American oriented.

    September 2, 2020 at 12:35 AM #41818

    Martin Kendall
    Participant

    That sounds great, though I’m more than happy with isFavourite – British English here! :-;

    Looking forward to the update, thanks,

    Martin

    September 10, 2020 at 2:44 AM #41903

    Marcus
    Participant

    May I make suggestions ?

    – swipe between favorites would be very helpful
    – Loop over all favorites, for instance “var records = favorites.getRecords()”

    September 10, 2020 at 11:49 AM #41908

    Brendan
    Keymaster

    Good suggestion. I’d have to expose a document.getFavourites() function.

    September 10, 2020 at 11:17 PM #41913

    Marcus
    Participant

    Perfect, thanks

    And (please, please, please) add the possibility
    to swipe between the favorites.
    It‘s annoying to go back to the list to
    open the next recordset ?

    btw.: iOS on iPhone.

    February 29, 2024 at 5:49 AM #50573

    FrAnksch
    Participant

    Is this feature available in the meantime?

    I’m currently looking for a way to mark the current dairy record (of “today”) as favourite automatically via script…

    February 29, 2024 at 10:31 AM #50574

    Daniel Leu
    Participant

    Yes it is: console.log(record.isFavourite).

    March 2, 2024 at 1:36 AM #50576

    FrAnksch
    Participant

    Daniel, thank you very much.
    Since I’m a script newbie, I had a problem to set this “isRecord” property, but now after several trials, I finally figured it out.

    one additional question:

    With my script below, I mark the current entry of my dairy (“today’s record”) greenish and as favorite.
    Therefor I use a “helper calculation field” (tageseit) that calculates the difference between date of record and today (>>DAYS(X;Y)<<),  which then is checked in an if query.
    This is working as expected, but how can I get this calculation (of entire days) done in the script? If I calculate with date fields, I get “seconds” as result, not entire days.

    Thanks for your help!

    my Script:

    function SkriptMarkToday() {

    var tageseit_id = ‘fld-6826c8b388e046c5ab5b10144fe499db’;
    var tageseit = record.getFieldValue(tageseit_id);
    var forcefav_id = ‘fld-aa6d11f990724703969cd07d85037f71’;
    var forcefav = record.getFieldValue(forcefav_id);

    form.selectRecord();

    if (tageseit == 0) {
    record.setRecordColor(“#66DD77”);
    record.isFavourite=1;
    console.log(“als heute und als FAV markiert”);

    } else {
    if (forcefav == 0) {
    record.isFavourite=0;
    console.log(“FAV deaktiviert”)
    }
    record.setRecordColor(null);
    console.log(“nicht heute”);
    }
    form.saveAllChanges();

    }

    SkriptMarkToday();

    • This reply was modified 8 months, 2 weeks ago by FrAnksch. Reason: Tried to format the code - don't know how
    • This reply was modified 8 months, 2 weeks ago by FrAnksch.
    March 2, 2024 at 4:21 AM #50579

    FrAnksch
    Participant

    I found a solution that seems to work. I have to format the two date fields as “date only”, without time.

    Is this a suitable way to do this?

    var datum = record.getFieldValue(datum_id).toLocaleString().split(‘,’)[0];

    var today=new Date().toLocaleString().split(‘,’)[0];

    Thanks!

Viewing 9 reply threads

You must be logged in to reply to this topic.