Setting Current Date

Viewing 4 reply threads
  • Author
    Posts
  • September 1, 2023 at 3:18 AM #49800

    John Juhl
    Participant

    Hi guys,

    I’m trying to figure out how to make this work:

    • I have a CheckMark field
    • and would like to make value in a Date field change
    • when the CheckMark field is Checked

    I’ve tried different Script Approaches, with no luck so far

    How would I do this?

     

    kr.

    John

    September 1, 2023 at 1:26 PM #49802

    Brendan
    Keymaster

    Hi John,

    What script have you written to do this?

    Something like this should work:

    function setCurrentDate() {
    var check_field_id = "fld-.....";
    var date_field_id = "fld-....";
    var check_value = record.getFieldValue(check_field_id);
    if (check_value == 1) {
    record.setFieldValue(date_field_id, new Date());
    }
    form.saveAllChanges();
    
    }
    
    setCurrentDate();
    • This reply was modified 1 year, 3 months ago by Brendan.
    • This reply was modified 1 year, 3 months ago by Brendan.
    September 3, 2023 at 1:06 PM #49811

    John Juhl
    Participant

    Hi Brendan,

    thanks for your reply – I don’t recall at the moment what I tried, but from what I can read out of your Script I did get the check-field syntax wrong, since I worked with true/false instead of 0/1.

    It’s a bit late here in Denmark right now, but I’ll have a play with your script first thing in the morning.

     

    Thanks,

    John.

     

    September 3, 2023 at 11:08 PM #49812

    John Juhl
    Participant

    Works like a clock :)

    Another Question:

    Is it possible to make fields visible depending on values in other fields (conditional)?

     

    kr, J-)

    September 4, 2023 at 11:07 AM #49813

    Brendan
    Keymaster

    Hi John,

    Well, sort of. But because fields are on a form basis, if you hide a field in one record, it will hide that field for every record.

    field.hideField = true;

Viewing 4 reply threads

You must be logged in to reply to this topic.