Desk Contact Name > split to First and Last name

Desk Contact Name > split to First and Last name

I am new to Zoho and while setting up the Desk and Help Center, I saw that new tickets created or submitted from the Help Center used the Contact Name field. This would create a new Contact but put the person's name in the Last Name field only. The First Name field would be blank.
I read another community post about this here: Contact Name - First and Last Name (zoho.com), but the formula did not work for me (probably from not understanding Deluge script.

Upon asking for help from the Zoho team, here is their Custom Function solution:

  1. Navigate to Setup > Automation > Workflows
  2. Create Rule
  3. Execute on > Create (check this box)
  4. Criteria > First Name | is empty
  5. Actions > Custom Function
    1. Name = split_name
    2. Module = Contacts
    3. Argument Mapping (see attached screenshot for reference)
      1. Name = Lname, Value = Contacts.Last Name
      2. Name = Id, Value = Contacts.recordid
  6. SAVE
  7. Navigate to Setup > Developer Space > Functions
  8. Create a New Function
  9. Name = split_name
  10. Category = Automation
  11. Module = Contacts
  12. Write the Deluge code below, using your own Organization ID (see attached screenshot for reference):
  13. Save
  1. orgid = xxxx;
    if(lname.contains(" "))
    {
    zoho.desk.update(orgid,"contacts",id,{"lastName":lname.getSuffix(" "),"firstName":lname.getPrefix(" ")});
    }

That should be it.
I hope this helps others who run into the same problem.