Setting values for lookup datasource fields

Hello,
I am using the API to create Employee Onboarding requests in FreshService. Three fields on the employee onboarding form are lookup fields using FreshService datasources (these are not custom objects). I’ve looked through the API documentation and I cannot find any guidance on how to set a value for this type of field.

As an example, my onboarding form includes a required lookup field for Reporting Manager. I would like to set Reporting Manager to be Bob Smith, a user in FreshService. How would I go about doing that? I’m using the code below to test with, and in this code “actor_3” is the lookup field I want to set to Bob Smith. The code below returns an error “invalid field value for field”.

curl -u kkkkkkkkkkkkkk:X -H “Content-Type: application/json” -X POST -d ‘{ "fields": { "cf_employee_legal_name": "Andrea Smith","cf_employee_preferred_name_display_name": "Andrea Smith", "cf_date_of_hire": "2022-08-20","cf_employee_type": "Salary","cf_department": "Purchasing","cf_job_title": "Purchaser","actor_3": "Bob Smith","cf_shift": "First","cf_location": "Facility 1","cf_description_additional_info": "some notes"}}’ https://domain.freshservice.com/api/v2/onboarding_requests

Any help is appreciated.

Hi @blabarbera,

Welcome to the community :tada:

Perhaps, try replacing the actor value from “Bob” with the user ID (requester ID).

This might help you, let me know otherwise.

Thank you.

Hello, I’ve been able to correct issues with 2/3 fields that were returning errors (thank you for the suggestion), but a third field does not seem to accept a value in the same way that the other lookup field does. The first example below works and the cf_location lookup field accepts the location id number.

The second example does not work, yet I am passing a valid department id to the cf_department lookup field. Is there something else I’m missing here? My expectation is that both lookup fields accept the id values in the same way.

WORKS -
curl -u xxxxxxxxx:X -H “Content-Type: application/json” -X POST -d ‘{ "fields": { "cf_employee_legal_name": "Andrea Smith","cf_employee_preferred_name_display_name": "Andrea Smith", "cf_date_of_hire": "2022-08-20","cf_employee_type": "Salary","cf_job_title": "title","actor_3":"jsmith@domain.com","cf_shift": "First",**“cf_location”:21000230355,**"cf_description_additional_info": "some notes"}}’ https://domain.freshservice.com/api/v2/onboarding_requests

DOESN’T WORK -
curl -u xxxxxxxxx:X -H “Content-Type: application/json” -X POST -d ‘{ "fields": { "cf_employee_legal_name": "Andrea Smith","cf_employee_preferred_name_display_name": "Andrea Smith", "cf_date_of_hire": "2022-08-20","cf_employee_type": "Salary",“cf_department”:21000199630,"cf_job_title": "title","actor_3":"jsmith@domain.com","cf_shift": "First",**“cf_location”:21000230355**,"cf_description_additional_info": "some notes"}}’ https://domain.freshservice.com/api/v2/onboarding_requests

Hello @blabarbera, perhaps try using the department name as a string instead of the ID?

One thing you could try is creating the onboarding request through the UI and then use a GET request to get back the ticket details, that response would have values for your custom fields, hopefully indicating the value types it is looking for. Just a thought. Take care.

That’s what I did to get the values I am now trying to set via the API. That’s why it doesn’t make any sense.

I’ve opened a ticket with FreshService to see if they can shed light on the issue.