Discussions

Expand all | Collapse all

Auto population of data on form loading

  • 1.  Auto population of data on form loading

    Posted 03-01-2017 06:02
    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


  • 2.  RE: Auto population of data on form loading

    Posted 03-01-2017 06:35
    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.


  • 3.  RE: Auto population of data on form loading

    Posted 03-01-2017 09:17
    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 ?


  • 4.  RE: Auto population of data on form loading

    Posted 03-01-2017 17:27
    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.


  • 5.  RE: Auto population of data on form loading

    Posted 03-02-2017 07:39
    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. 


  • 6.  RE: Auto population of data on form loading

    Top
    Contributor
    Posted 03-04-2017 23:30
    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.


  • 7.  RE: Auto population of data on form loading

    Top
    Contributor
    Posted 03-01-2017 16:28
    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


  • 8.  RE: Auto population of data on form loading

    Posted 03-02-2017 07:41
    Hi
    i am not maintaining any 'add employee job' button. Independently, the form needs to be loaded with the data from master.
    Thanks