最近の検索


最近の検索はありません

Zendesk API Custom Fields

回答済み


投稿日時:2016年10月13日

Is that possible to get custom field value from ticket using custom field name in zendesk apps ?


0

18

18件のコメント

公式

Here's the syntax for getting a custom field's value:

client.get('ticket.customField:custom_field_12345678')

...where the '12345678' value is *your* custom field's unique ID, prefixed by the literal string "ticket.customField:custom_field_"

This is documented here:

https://developer.zendesk.com/apps/docs/apps-v2/support_api#ticket.customfieldfieldname

One way of getting your custom field's ID value in Zendesk is by going to to Admin > Manage/Ticket Fields > edit -- it will be listed at the top of the Ticket Field Edit page.

 

0


@mccabe.tonna I am unable to get the value of a custom field. Following is the code I wrote. Is there something I am doing incorrectly ?

I have tried all possible ways but no luck. Basically I want to read value from one custom field and set it to another custom field. It works fine when I try to assign hardcoded string. But the get part somehow isn't fetching the field information.  

 

const client = ZAFClient.init();

const getAccountName = document.getElementById('get-account-name-button')

const getAccountNameFunc = async () => {
  //let myData = client.get('ticket.customField:custom_field_4614118609940')
  let myData = client.get('ticketFields:custom_field_4614118609940')
  //let myData = client.get('ticketFields')
  //client.get(['ticket.customField:custom_field_4590824941204']).then(function(data){
let myString = JSON.stringify(myData);
client.set('ticket.customField:custom_field_4731199018772', myString)
}
client.on('app.registered', function () {
});
getAccountName.addEventListener('click', getAccountNameFunc);

0


@Administradores IZA

Great!, you can add multiple objects within that get function [array], then when setting values, point each variable to each item in the array

0


Thank you McCabe!! Worked perfectly!!!

0


@Administradores IZA

Set or get?

If you're trying to set a value you need to include what value you're trying to set - zafClient.set('ticket.customField:custom_field_360018041180', value)

but a Get could look like the following if you want to store to a var - i use this method below to get multiple values at once

client.get(['ticket.customField:custom_field_360018041180']).then(function(data){

     let value = data['ticket.customField:custom_field_360018041180']

})

0


Hello, I´m trying to set a value on a custom field

But it´s returning a Promise

I got the ID from the top page
Any help, please?

 

Tks!

 

0


Hi Brandon. It is a bit confusing. There's the ticket field's meta information (the example you gave), which is the "schema" of the field, no matter the ticket. Then there's the custom field's actual value stored for a given ticket.

To get the a custom field's value for the currently displayed ticket use:

client.get('ticket.customField:custom_field_123456789')

Hope this helps!

0


All of these answers seem to point to how to SET the value of a custom field despite the original question asking how to GET the value of a custom field. This is the closest forum I've found regarding the issue I have but it also looks like many moderator's comments have been redacted and URLs are no longer valid. As far as I can tell, the following approach seems like the most appropriate endpoint for the .get method of the ZAFClient initialized object.

client.get('ticketFields:custom_field_123456789').then(function(data) {
console.log(data);
}

yields:

{
hasOptions: boolean,
isEnabled: boolean,
isVisible: boolean,
label: "Name of Field",
name: "custom_field_123456789",
requireOnStatuses: Array [],
type: "regexp",
}
 

How do you get the actual value of the field? Is there another way to go about getting the value of a custom field and I'm just not seeing it in the docs?

0


Thanks for sharing, Prashanth!

0


This worked :

 

client.get('ticket.customField:custom_field_360010330451').then(

function(data){

var fieldValue= Object.keys(data)[1];
console.log( data[fieldValue]);

}
);

0


Apologies if this is a late answer, but this method works for me:

client.get('ticketFields').then(function(data) {

// Get all fields to query against
var fields = data["ticketFields"];
var CustomFieldName;

// Iterate through each field
for (var field in fields) {

// Find the one that match
if (fields[field].label == "Your Custom Field Name") {
// console.log(fields[field].label);
// console.log(fields[field].name);
// Grab your custom field ID
CustomFieldName = fields[field].name;
}
}

// Do some custom field magic for your Zendesk
client.set('ticket.customField:' + CustomFieldName, DataForYourField).then(function(data) {
// https://SomeDomain.zendesk.com/api/v2/ticket_fields
console.log(data); // { 'ticket.subject': 'Printer Overheating Incident' }
});

});

Happy Coding!!

 

 

0


サインインしてコメントを残します。

お探しのものが見つかりませんか?

新規投稿