Announcement

Collapse
No announcement yet.

Assigning a job title in script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Assigning a job title in script

    Hi, I am creating a Contact record in script within a BPM.

    This is working well but I am stumped when it comes to assigning the Job Title. I have assigned the Account ID which works great. I have then tried to use the variable accountRole assuming that it was the role within that account. Seems not. Can you suggest how I do this please?

    Below is a screen shot of my current definition. Right now the correct job title is being assigned to "description" which is right. I would have expected the Job Role would be "Mat", but it is empty.

    Pointers appreciated.

    Click image for larger version

Name:	Create Contact.png
Views:	248
Size:	35.4 KB
ID:	59085

  • #2
    Hi Mat,
    In BPM you have to use bpm\targetEntity\attribute(ATTRIBUTE) instead of targetEntity\attribute(ATTRIBUTE). Try this:
    Code:
    description = bpm\targetEntity\attribute('title');
    Read more here: https://github.com/espocrm/documenta...mula-functions
    Last edited by Maximus; 06-04-2020, 12:04 PM.

    Comment


    • #3
      Hi Maximus thanks for the response.

      The issue is not retrieving the data (that actually works when I look at the "description" field, but I will make your change anyway). The issue is that I cannot set the job title. In the above code I would have assumed that it is set to "Mat", but it is empty. Am I using the correct attribute? Is there something else that I should do?

      Comment


      • #4
        Ok, I have simplified the entire process. I now just have the simple process below which has 2 lines of code. All I am trying to do is extract the current accountRole, and then assign it a new value. The extraction returns an empty string, and the assignment has no effect.

        From what I can understand the accountRole is not a real attribute, so the code that handles it is probably broken. The attributes accountId and accountName work fine.

        Thanks.

        Click image for larger version

Name:	Account Role.png
Views:	179
Size:	40.5 KB
ID:	59095

        Comment


        • #5
          Mat, this works for me:
          Code:
          description = title;
          title = 'bodyguard'
          but note:
          - It will affect only the primary account title;
          - primary account title will be changed in the database at the same moment as you trigger BPM, but on your layout you may continue gazing the same title. Just press F5 to refresh a web page.

          Comment


          • #6
            Use record\updateRelationColumn https://docs.espocrm.com/administrat...relationcolumn to update title for a specific account.

            Comment


            • #7
              That got it great.

              One final question, what is the accountRole attribute for then?

              Comment


              • #8
                For displaying on relationship panel. You can find more info in entityDefs https://github.com/espocrm/espocrm/b...tact.json#L156

                directUpdateDisabled means that it can't be updated;
                notStorable means it's not stored directly in DB;
                layoutAvailabilityList defines in which layouts it will be presented (for layout manager).
                Last edited by yuri; 06-05-2020, 11:30 AM.

                Comment

                Working...
                X