Default Value Of User

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnapriya
    Senior Member
    • Aug 2017
    • 209

    Default Value Of User

    Hi,

    In accounts, assigned user shows the name of logged in user by default.

    I have one departments field in which I want to show department of the logged in user by default.

    Please help.

    Thanks Click image for larger version

Name:	Untitled.png
Views:	694
Size:	24.2 KB
ID:	31306
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    The easiest way is set the value of this field with Formula. But this field will be filled only after save (you can add a condition if field is not set, then set it).
    if you want to make this field prefilled, you need to override the view of this field and set the value there

    Comment

    • krishnapriya
      Senior Member
      • Aug 2017
      • 209

      #3
      Thanks for your reply Tanya.

      Formula for a text field works fine. I am confused in case of related field like departments.

      As you said I want the field to be prefilled. I tried like this.
      Click image for larger version

Name:	Untitled1.png
Views:	714
Size:	15.3 KB
ID:	31332

      But not working. I am new to EspoCrm. Please help.

      Thanks.
      Attached Files

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        this.model.get('assignedUser.departmentId') ? don't think the model has this value (you always can print data in log and check, what does contain the model)... if you need data of logged user use
        Code:
        this.getUser().get('....')

        Comment

        • krishnapriya
          Senior Member
          • Aug 2017
          • 209

          #5
          Can you please tell me where should I define departments field?

          I created departments.js file in client\custom\src\views\account\fields

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            you could create the file there. but you need to set the the view of field in entityDefs

            Comment

            • krishnapriya
              Senior Member
              • Aug 2017
              • 209

              #7
              it Worked. Thanks tanya.

              Comment

              Working...