I'm looking for an Apps Script to auto-populate a User Field (Requester) with the name of the currently logged in user - the one creating the record.
I've followed the sample in the Dev Apps Scripts page (below), but the field is not populating.
The scripts is saving with no errors, and I've tried both Before Insert and After Insert. I want the name to display before saving the record so the user will have one less field to click on (unless they want to change the name).
How do I change a value in the current record ?
currentValues["Status"] = “Active” currentValues[“Age”] = 20;
John McGarvey commented
Adding to this request with a slight change.
I have created own User table so I can add attributes that are not available in the system's User table, plus being able to have names displayed in the format I want, such as:
Smith, John instead of John Smith<firstname.lastname@example.org>
I am slowly moving all my tables to reference my custom User table when there is a need for a user field, so the drop-down:
1) Displays alphabetically by last name
2) Much cleaner look in the application
3) Filtered lookup view with no displayed inactive accounts (my User table has a status flag)
Each record in my User table has the system Application User field populated with the system user account so I can use it for filtering for "currently logged in user", etc. All I have to do is set the filter up to the parent table instead of the local table.
What I would like to do is have an Apps Script populate my LTP field to my custom User table using the format of the name I have as the Record ID.
Is it possible for a script to:
1) Grab the currently logged in user's account
2) Go to the parent table and look for the Application User field on the record (which is not the Record ID)
3) Associated the system user account to the Record ID of my table
4) Populate the child table with the format from my parent table's Record ID for the currently logged in user.
I know the above if pretty wordy, but wanted to be clear on what i am looking for.
I too would like to auto-assign a User Group or Application user (preferably user group) upon the creation of a record. I.e if I have a vendor(limited user) adding assets to a table, all records would populate the User Group field with that of the Application User.
I have also tried the suggested work-around mentioned below, however there is no "Current logged-in User" default option for User fields when i add them to a form... I am simply given a list of application users to choose from. Could you share a screenshot where i am shown this default option selected when setting up a form?
Thank you for contacting TrackVia Support. Unfortunately, it is not possible to perform this action before the record is created, as the Created By field is not stamped with a User's name until you hit the Save button. Alternatively however, you could create a custom form where the User field's default value is set as "Current Logged-in User" to achieve the same result.
I am not entirely sure what you are asking in your second question. Could you clarify please?