record\count and counts by user

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cardigansam
    Junior Member
    • Oct 2022
    • 12

    #1

    record\count and counts by user

    When using record\count, I can't seem to find the correct iteration of createdBy to return a result to the record\Count. We would like to be able to create some statistics about users submitting leads (in this example, by day).

    In the formula sandbox, i select a lead and run:
    Code:
    output\printLine( record\count ('Lead', 'biddate=', biddate) );
    and I get a return of 12. If I expand that to the createdBy field, I can't get it to give a result of anything other than 0. e.g.:
    Code:
    output\printLine( record\count ('Lead', 'biddate=', biddate, 'createdBy=', createdBy) );
    I have tried [ 'createdby.Name=', createdBy.Name ] but it throws a Server 500 error. The traditional methods of fieldId or fieldName (createdById or createdByName) also don't seem to work in this context.

    Is there a way to use a User in this regard in formulas? The formula script reference didn't seem to bring Users up as a special case anywhere that I saw at https://docs.espocrm.com/administrat...ula-functions/
  • lazovic
    Super Moderator
    • Jan 2022
    • 1040

    #2
    Hi cardigansam,

    Please try to use the following formula script in the Formula Sandbox:
    Code:
    output\printLine(record\count('Lead', 'biddate=', biddate, 'createdById=', createdById));

    Comment

    • cardigansam
      Junior Member
      • Oct 2022
      • 12

      #3
      It worked. Now I'm at a loss as to why your copied line worked and my attempts didn't. Thank you, lazovic. You put the super in super moderator.

      Comment

      • lazovic
        Super Moderator
        • Jan 2022
        • 1040

        #4
        cardigansam,

        The whole point is that different field types have multiple attributes and their attribute naming.

        In this case, the field createdBy is a field with the Link type, and to access its values, we need to use the following attributes: createdById, createdByName.

        You can read about this in the documentation here: https://docs.espocrm.com/administrat...ing/#attribute.

        Comment

        • yuri
          Member
          • Mar 2014
          • 9006

          #5
          It's possible to see attributes of a specific field (as of the recent version). Administration > Entity Manager > {Entity Type} > Fields > dropdown on the right in a field row > View Details.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • cardigansam
            Junior Member
            • Oct 2022
            • 12

            #6
            Originally posted by lazovic
            cardigansam,

            The whole point is that different field types have multiple attributes and their attribute naming.

            In this case, the field createdBy is a field with the Link type, and to access its values, we need to use the following attributes: createdById, createdByName.

            You can read about this in the documentation here: https://docs.espocrm.com/administrat...ing/#attribute.
            Yes, but I tries "CreatedByName" and "CreatedById" and it didn't work. But it worked when I copied yours. I'm not sure what I did wrong.

            Comment

            • lazovic
              Super Moderator
              • Jan 2022
              • 1040

              #7
              cardigansam,

              Perhaps you entered attributes with a capital letter? Not createdById, but CreatedById? In that case the formula script wouldn't work.

              Comment

              • cardigansam
                Junior Member
                • Oct 2022
                • 12

                #8
                I could certainly see myself doing that without noticing that I did so.......

                Comment

                Working...