How to Assign a user to a User Link field?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Triggerz
    Senior Member
    • May 2024
    • 134

    #1

    How to Assign a user to a User Link field?

    Hi,

    I created a custom entity called Helpdesk to record requests from our employees. It has a link field called handledby to the User entity and a field called ReqType.
    When creating or editing records, I wanted to assign specific users to the handledby field depending on the chosen ReqType.

    For example :

    If Type is "Payrol Request" it should be assigned to Sheryl
    If Type is "Leave Request" it should be assigned to Edward

    I created the below code in Formula API Before Save Script of the Helpdesk entity but I could not assign the correct user. Please help.

    Code:
    $prevType = entity\attributeFetched('reqtype');
    
    if (reqtype != $prevType) {
    
    if (reqtype == 'Payroll Request') {
    userName = 'Sheryl Adams';
    userId = 'sadams';
    }
    
    if (reqtype == 'Leave Request') {
    userName = 'Edward Adams';
    userId = 'eadams';
    }
    
    }



    Thanks in advance...
  • murugappan
    Active Community Member
    • Aug 2017
    • 528

    #2
    Hi Triggerz

    You need to create a workflow (you need advance pack extension). Try to use and customize this. Hope it proves useful and addresses you needs.

    Click image for larger version  Name:	Screenshot_3.png Views:	0 Size:	47.6 KB ID:	124466

    Comment

    • Triggerz
      Senior Member
      • May 2024
      • 134

      #3
      Hi Murugappan,

      Thanks for your response. Actually the script is able to update the Handled By field. The only problem is it is not being updated properly. Maybe the reason is the value that I am assigning is not correct. Please see screenshot below. If I click the newly assigned Handled By, it directs to 404 because it could not find the actual user.

      Not sure if I am assigning the wrong value or updating the wrong fields (userName and userId)

      Click image for larger version

Name:	image.png
Views:	0
Size:	23.7 KB
ID:	124468

      Comment


      • murugappan
        murugappan commented
        Editing a comment
        Is sadams is a user in the system, there is an attribute called assigned.user.name and assigned.user.id. Try using the assigned.user.name. But is has to be in a formula or workflow. Then when you click the name it should pick-up the user record.
    • Triggerz
      Senior Member
      • May 2024
      • 134

      #4
      Hi Murugappan,

      I was able to make it work. Apparently, I was assigning the wrong value to the userid. Once I updated it to the corred userid value, all worked well.

      Thanks for responding to my question.

      Comment

      Working...