Auto population of data on form loading

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • In Progress
Hi,

This is my situation, 
I have two tables employee_master and employee_job. In employee_master table, i have userid, empid,name,email.
In employee_job, i have userid,empid,designation,department etc. What i want is, when i load employee_job form, empid should be auto populated from employee_master based on userid(current user). Is there any way to do this without any trigger.

Thanks
Photo of Shihad

Shihad

  • 496 Points 250 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Thete us a simple way and a more complicated way.

The simple way,especially if there are no other relationships involving the Employee master table is to change the Key field of the employee master table to the userid.

Note that you may want to Copy your app to try this first.

Then, on your jobs table, you can have a formula field called [Current User] with a formula of User()

Lastly a form rule that says

When the field related armployee is blank change the related employee field to be the value in the field Current User.

Note that the field that the form rule is acting on will be the field which is used in the relationship to the employer table.
Photo of Shihad

Shihad

  • 496 Points 250 badge 2x thumb
Hi ..i am trying this solution. For that i created a current user formula field in employee job form. Then created a relationship between tables. But i couldnt create  the form rule properly. can u make it more clear?

Or any other way without using relationship. or using javascript ?
(Edited)
I'm not sure how else to say the form rule

Condition:
When the field related armployee is blank

Action:
change the related employee field to be the value in the field Current User.
Photo of Shihad

Shihad

  • 496 Points 250 badge 2x thumb
Thanks
But the issue is, 
i saved one record in employee job. Then, another user logged in ,that time the already saved record is showing in his name. 
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
Make the form rule that is making the change have another condition. Where it doesn't fire when the field is already filled out.

You might take a look at your process a little,  because this all seems a little sideways.  But we are only getting a small portion of the real question.
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
Yes,  The best way, which is also the easiest. is to slightly modify the button you are pushing from the master table.

You probably have a button called "Add Employee Job"  you just need to insert one small line.

Yours might look something like this:

URLRoot() & "db/" & [_DBID_EMPLOYEE_JOBS] & "?a=API_GenAddRecordForm&_fid_12=" & URLEncode ([Record ID#])& "&z=" & Rurl()

Just add another fid to be written to:
You can copy the format of part of the code:  &_fid_12=" & URLEncode ([Record ID#])& "

Change the fid from 12 to the field id that has your "empid" then if it is a user insert (User())
Like this:

&_fid_12=" & URLEncode (User())& "

#NoCodeRequired
Photo of Shihad

Shihad

  • 496 Points 250 badge 2x thumb
Hi
i am not maintaining any 'add employee job' button. Independently, the form needs to be loaded with the data from master.
Thanks