Fetching user details in a function in ZOHO CRM

Fetching user details in a function in ZOHO CRM

I am trying to get the user details for a record owner so that I can use them in my function.  We have a specific business case for franchise organizations.  We have over 100 of our franchises using a single instance of our CRM.  We need to have a contact record be stamped with the franchise name based on the record owner.  For this we are trying to get the franchise name from a custom field we added to the user record.  We would love to get the role -but that does not seem possible.  Here is the code I am using - I am able to get the getrecrods to return the correct user - but the data is not available to me when I try and create a variable from the getrecords result:  FYI - I have hidden the sensitive information below and highlighted the data that I want to get into a variable. 

Function:
//roleName = thisapp.permissions.roleForUser("john@zillum.com");
ROLENAME = zoho.crm.getRecordById("users",UserID.toLong());
ROLESEARCH = zoho.crm.searchRecords("users","(ID:equals:" + UserID + ")");
//roleNam1 = thisapp.permissions.roleForUser("julie.gip@gmailc.om");
info "result" + ROLENAME;
info "..................";
info "result" + ROLESEARCH;
info "..................";
RoleLocation = ROLENAME.get("Role");
Rolesearch1 = ROLESEARCH.get("Franchise_Location");
RoleLocation2 = ROLENAME.get("first_name");
RoleID = ROLENAME.get("ID");
info "Role: " + ROLENAME.get("Role_Name");
info "RoleID: " + ROLENAME.get("Id");
info "Roleloc: " + RoleLocation;
info "Rolesearch1: " + Rolesearch1;
info "Roleloc2: " + RoleLocation2;
info "..................";

Results:
Info
  • result{"users":[{"country":null,"role":{"name":"56-26-IL - Schaumburg","id":"hidden"},"city":null,"language":"en_US","locale":"en_US","microsoft":false,"Office_Phone":null,"Isonline":false,"Modified_By":{"name":"hidden","id":"hidden"},"street":null,"id":"hidden","state":null,"fax":null,"country_locale":"US","sandboxDeveloper":false,"first_name":"SS","email":"hidden","Reporting_To":null,"zip":null,"created_time":"2021-06-02T06:40:08-05:00","Franchise_Location":"Overland Park, KS","Modified_Time":"2022-05-03T11:30:59-05:00","time_format":"hh:mm a","offset":-18000000,"profile":{"name":"hidden","id":"hidden"},"mobile":null,"last_name":"hidden","time_zone":"America/Chicago","created_by":{"name":"hidden","id":"hidden"},"zuid":"hidden,"confirm":true,"full_name":"hiddden","territories":[],"phone":null,"dob":null,"date_format":"MM/dd/yyyy","Local_URL":null,"Secondary_Email":null,"status":"active"}]}
  • ..................
  • result{"users":[{"country":null,"role":{"name":"56-26-IL - Schaumburg","id":"hidden"},"city":null,"language":"en_US","locale":"en_US","microsoft":false,"Office_Phone":null,"Isonline":false,"Modified_By":{"name":"BB","id":"hidden"},"street":null,"id":"hidden","state":null,"fax":null,"country_locale":"US","sandboxDeveloper":false,"first_name":"SS","email":"Hidden","Reporting_To":null,"zip":null,"created_time":"2021-06-02T06:40:08-05:00","Franchise_Location":"Overland Park, KS","Modified_Time":"2022-05-03T11:30:59-05:00","time_format":"hh:mm a","offset":-18000000,"profile":{"name":"hidden","id":"hidden"},"mobile":null,"last_name":"hidden","time_zone":"America/Chicago","created_by":{"name":"hidden","id":"hidden"},"zuid":"hidden","confirm":true,"full_name":"hidden","territories":[],"phone":null,"dob":null,"date_format":"MM/dd/yyyy","Local_URL":null,"Secondary_Email":null,"status":"active"}],"info":{"per_page":200,"count":1,"page":1,"more_records":false}}
  • ..................
  • Role: null
  • RoleID: null
  • Roleloc: null
  • Rolesearch1: null
  • Roleloc2: null
  • ..................
Function executed successfully