How to use setValue in Freshservice for Data-Sourced fields

I have been trying to set a custom data-sourced drop down field using setValue inside client.interface.trigger() method. The field is sourced with “Agents” and I have tried using values such as Agent id, name, or email address and I am unable to get the Agent to populate in the field. This works with a text field, no problem.

So my question is, is there anything special regarding data-sourced drop down fields when it comes to trying to use setValue?

Thank you for any assistance.

Take care,
Zach

Hi @Zach

Are you looking something similar to setOptions in Freshdesk?
I believe same is not available with Freshservice.

@Sachin_Kumar Looks like it.

There is nothing that is specifically documented about dropdown in Freshservice docs > Documentation > Interface Methods.

@Zach Can you confirm that you are looking for a UI event to dynamically update a dropdown ticket property field? (Or similar to setOptions like Sachin is hinting at.)

@Sachin_Kumar @Saif, Yes I am trying to dynamically update a dropdown field. Specifically off of this freshservice documentation.

It indicates that custom fields are eligible to set values for using the “interface” method. I assume setOptions is designated for drop down fields but I don’t see that method available for freshservice.

Hi @Zach

My apologies as misunderstood your question/issue. I tried to replicate the issue and it looks like the method is not working for data sourced drop downs. It works fine for normal drop down options.

Interestingly, it tries to set the value for data sourced drop down also and enables the :heavy_multiplication_x: icon in the drop down field however since setting the data sourced property requires to first lookup the values and then populate options selected by user on UI. When you try to set the value from the APP the list of possible values on the UI is not available in the DOM and hence it is not setting the value of drop down.

May be if we get the ability to setOptions in code then probably this will work. I might be wrong.

Hello @Sachin_Kumar, no worries, I may not have described my situation accurately :smile: but this was my experience when I tried it as well. I noticed the “X” icon in the field just no value was populating.

Any suggestions on a possible solution? I need this field to be of the drop-down type so that I can then later filter tickets by it.

Usecase: Filter tickets using “Created By” (this would be the name of the data-source drop down field)

Appreciate your help!

Hi @Zach

Well this would not be the cleanest solutions but since the limitation of not being able to set options of dropdown,

  • Create a custom field of type number “Created By” and set it in app to the agent id.
  • Create custom app with a dropdown for agents which you can construct in app init and put a event listener for change on this drop down to reset the value of custom field. if required.
1 Like

Hi @Sachin_Kumar, when you say construct the agent dropdown in app init, you mean populate the drop down with the agent’s name each time the app runs?

Which field would I later use to filter the tickets? The “Created By” number field? Is that field available to filter tickets?

Appreciate all your help!

Hi @Zach

My apologies, this will not let you filter tickets on UI. I got confused with Analytics module where you can use numeric fields to filter data and suggested to keep the agent id in the numeric field.