Default values for new record based on where created

My app, being designed for scheduling and timesheet management, requires two data entry paths.

Path 1. If a user makes a new timesheet entry (for an unassigned job) he would select his name from the list of workers, then add a new record to the timesheet table. In that case the default needs to have the default date set for today, the start time set at 7:00, end time set at 15:06 and break time as 30 minutes.

Path 2 If the supervisor is building a schedule for the week he would come from the Jobs table, select a date, select an employee and add a new timesheet entry with the selected date and start time with no end or break time.

Is there any way to set defaults (initial values) based on the path used to get to an input form or send a parameter to the form that can be used to set the defaults?

Rob

Solved Solved
0 15 1,968
  • UX
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Not on the path to the form, but the column logic can examine the form name using CONTEXT(). For instance, the Initial value expression for the Date column could be:

IFS(
  ("Supervisor Form" <> CONTEXT("View")),
  TODAY()
)

Start Time:

IFS(
  ("Supervisor Form" <> CONTEXT("View")),
  "07:00"
)

and so on.

See also:

View solution in original post

15 REPLIES 15

You could use the option called โ€œReset on editโ€. If the supervisor creates that record, it doesnโ€™t fill anything like IFS(NOT(USEREMAIL()=โ€œadmin@email.comโ€),TIMENOW()). That will take care that it will use it as a default value if someone else than supervisor is creating the record.

When the employee updates the record it will generate the time value if you set the option โ€œReset on editโ€ as TRUE.

Thanks Aleksi. I guess that will have to do. It means that the Supervisor will need to be much more careful when he enters his own timesheets because the defaults will be wrong.

Wellโ€ฆ you can add that variable as well if he/she is doing an own timesheet.

Steve
Platinum 4
Platinum 4

Not on the path to the form, but the column logic can examine the form name using CONTEXT(). For instance, the Initial value expression for the Date column could be:

IFS(
  ("Supervisor Form" <> CONTEXT("View")),
  TODAY()
)

Start Time:

IFS(
  ("Supervisor Form" <> CONTEXT("View")),
  "07:00"
)

and so on.

See also:

Steve,
Does this work for Initial Value? I donโ€™t seem to have any luck using:

IFS(CONTEXT(โ€œVIEWโ€)=โ€œYacht Returnโ€,NOW())

Iโ€™ve got two forms pointing at the same table. Iโ€™m using one to checkin and one to checkout: โ€œYacht Returnโ€. The checkout form is a LinkToRow(). Not sure if this has anything to do with it.

Thanks, Mike

It should, yes.

By default, Initial value is applied only when the row is first added to the table, not each time the row is presented in a form. LINKTOROW() is used to navigate to an existing row.

I guess that did have something to do with it. Any solution to set an initial value to a LINKTOROW form?

The LINKTOROW has nothing to do with this. If you need the Initial Value expression to calculate anytime other than initial record creation, you should use the resetOnEdit property. In your case, simply enter this fragment of your existing expression:

Marc,

Thanks for the reply!
Where do I enter this fragmant? In the Initial Value field of the column?

Perfect! Thanks!

Also, your screenshot gave me another feature I need to add using contextโ€ฆthe โ€œDeviceโ€ context. 2 solutions in one! Thanks again!

Happy New Year! Viva LaAppsheet!

Ok, thanks. So that just means I need to somehow go to a different Input Form when a supervisor level entry is being added versus when a time sheet user entry is made.

However AppSheet seems to create its own Input_Form for adding new records with little customization available. I can make a copy of the input form and point it to a slice with only the fields I want added, but how do I make it use my Custom_Form to add a new record when I go from the Supervisor view to enter a Timesheet and use the standard input form when I go from the Timesheet view?

That is much trickierโ€ฆ

Do you have a table that ties the current userโ€™s email address to their supervisor status? That would make life so much easier!

Thanks Steve. Unfortunately that would just mean I need to create and maintain another table. Plus there are too many times when an employee needs to act as a supervisor. I will work out another alternative.

Hello,
I am trying to set [type] = 12 of tbl_function, if the View โ€œTasksโ€ is being opened
I used the following on the initial value of the [type] column of the tbl_function table,
IFS(CONTEXT(โ€œVIEWโ€)=โ€œTasksโ€, 12 )
without luck
the column on both โ€œTasksโ€ view, and other views using this table, are blank on initial value

May I ask what I have done wrong?

Top Labels in this Space