Link portal created Case with Account of Portal User

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WMEspo
    Member
    • Sep 2018
    • 33

    Link portal created Case with Account of Portal User

    I am trying to get my user portal working. I have the portal working fine, the only thing they have is access to is creating cases. When they create a case I would like to assign the Account that the Portal User is linked to, to the case itself without having to do it manually. The Portal User is already linked to their Account, but I am not able to create a link or update any fields using a work flow or a before save custom script on the Case. I'm sure this is possible, but I am just doing something wrong.

    Thanks for your help as always.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello,
    you can set it in Formula for Case entity.
    flow is
    - if current user is Portal and accountId is set
    - if Case isNew()
    => set case accountId = current user's accountId

    Comment

    • WMEspo
      Member
      • Sep 2018
      • 33

      #3
      Thank you Tanya, but I couldn't get this to work. I tried
      Update Target Record » Case
      accountName = createdBy.accountName;

      and

      accountId = createdBy.accountId;

      Your documentation doesn't have a attribute for current user so I was attempting to use createdBy. I can see the workflow is triggered in the workflow logs, but nothing is being set. The portal user definitely has an account associated with them.

      Thanks.

      Comment


      • rabii
        rabii commented
        Editing a comment
        Hey WMEspo,

        did you manage to solve this, I am facing the issue issue but seems the createdBy.accountId doesn't return anything although the user is linked to an account.

        Any clue ?

        Thanks
        Rabii
    • espo_rocks
      Junior Member
      • Feb 2019
      • 1

      #4
      Hey WMEspo,

      Sounds like you want Cases created by a Portal User to be linked with their Account.

      1. Create an Account.
      2. Create a Contact for that Account.
      3. Create a Portal User from that Contact.

      Now, when that Portal User creates a Case, the Account field will be auto-filled with the linked Account.

      Should work for any entity with an Account field, e.g. Opportunities, Tasks, Contacts, Knowledge Base, Documents, etc.

      Hope that helps.

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #5
        Hey all,

        I have come across the same situation. I have a parent field on lead called (salesChannel) the parent field has Account - User - Contact, I tried to update this parent field when a lead is created (if lead is created by portal I set up the salesChannelType = "Account" - salesChannelId = createdBy.accountId - salesChannelName = createdBy.accountName but it doesn't work.


        NB: when a lead is created by a normal user the salesChannel field is updated as (salesChannelType = "User" - salesChannelId = createdById - salesChannelName = createdByName ) and it works just fine, only when I a lead is created by portal user then it won't update the salesChannel parent field. I am sure that the portal user has account set.

        Can anyone help please.

        Thanks
        Rabii
        Web Dev

        Comment

        • eymen-elkum
          Active Community Member
          • Nov 2014
          • 472

          #6
          Hi Rabii,

          You have to relay on accountsIds instead of accountId, because the link between User & Account is many to many.

          The accountId is somehow calculated in some places for the default account of the user, and possible to not initiated while formula.
          CEO of Eblasoft
          EspoCRM Expert since 2014
          Full Stack Web Developer since 2008
          Creator of Numerous Successful Extensions & Projects​

          Comment


          • rabii
            rabii commented
            Editing a comment
            thanks @eymen-elkum

            I have managed to sort it out using some built in formula functions.

            Thanks
            Rabii
        Working...