0

Help with Button that inputs Date into parent record

Chronos is a subtable of Leads.  When creating a Chrono, I have made an option that allows a user to push the button to create an "Active Date" that matches with the Date of the Record in the chrono and puts it into the correct field in the Parent Table.  I am trying to find a way that it only puts that into the connecting records and not all records in the parent table.  Here is the following code that executes...but this code puts the date into ALL records in the parent table.

 

alert("This will set this Lead's first Activity Day as the Date of this Chrono.  Please click 'OK' to confirm");
let xDate := date('Date + Time');
(select Leads).('Active Date' = xDate)

3 replies

null
    • Fred
    • 8 mths ago
    • Reported - view

    Your third line says to get all records in Leads (select Leads) and change the 'Active Date' of all records that was selected to equal the xDate.

    You said Chronos is a subtable of Leads, so there is a reference field called Leads. If you only want to change the 'Activity Date' of the parent record in Leads you can just use Leads.

    alert("This will set this Lead's first Activity Day as the Date of this Chrono.  Please click 'OK' to confirm");
    let xDate := date('Date + Time');
    Leads.'Active Date' = xDate
    

    It is interesting that you don't allow the user to cancel the changing of the field. Maybe it should be a dialog field instead? Otherwise, why even have the alert.

      • Dave_Irving
      • 8 mths ago
      • Reported - view

      I was able to fix it with this using Leads as a reference instead of a whole table.

       

      do as server
          alert("This will mark today as this Lead's first Activity Day.  Please click 'OK' to confirm");
          let xDate := date('Date + Time');
          let xLead := Leads;
          xLead.('Active Date' := xDate)
      end
      

      Is there an ability I can give a user the ability to cancel it?  That would be nice, because I do want to prevent accidental clicking.

      • Fred
      • 8 mths ago
      • Reported - view

      Look into the dialog() function.

      You will need to take out the do as server as alerts and dialogs will not show to the end user if they are run on the server.

      This code is very quick so you won't see any performance difference. You can save a line of code by NOT putting Leads into a variable. There is no benefit to put Leads into a variable.

      If you wanted to reference a field in Leads then putting it into a variable can make things easier.

Content aside

  • 8 mths agoLast active
  • 3Replies
  • 36Views
  • 2 Following