The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the idValue of a customField inside a customFieldItem array ? (Using GoogleScripts)

Filipe
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 1, 2022

So i have a 'customFieldItems' array inside a certain card. So far i can acess any position of this array using the id of that position and using this url:

https://api.trello.com/1/cards/cardId/customFieldItems/customField_Id/?&key=api_key&token=api_token;

 

But inside this array there is a DropDown customField and i need to change the value of the selected option of this dropdown list(in my case this dropdown is in the position 1 of the 'customFieldItems' array).
I figured that the idValue is the id that i need to change but im not able to do that .
So far i got this:
var data = { "idValue""624460fc7dee1f1f8c5bce68" }; // This is the new id that i want to put
var options = {
    "method""put",
    "payload"data,
    "contentType""application/json"
  };

The URL: 

https://api.trello.com/1/cards/cardId/customFieldItems/customField_Id/?&key=api_key&token=api_token

 

var response = UrlFetchApp.fetch(url,options);

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 1, 2022

@Filipe 

You might want to check the api. From my python wrapper code it seems that the structure of should be this ...where custom_field.id is the definition id

/card/' + self.id + '/customField/' + custom_field.id + '/item

and 

post_args = {'idValue': list_field_id}

the value of idValue is the id of the option you have in that CFD.

Filipe
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 4, 2022

hey @milynnus  Your solution works ! Thank you!!

I addapted to the GoogleScripts like this : 

var id_Value ='IdValue here' ;

data = { "idValue"id_Value };
      options = {
        "method""put",
        "payload"JSON.stringify(data),
        "contentType""application/json"
      };
var key_and_token = "key=" + api_key + "&token=" + api_token;
var id_cfield = 'IdCustomField here';

var response =
UrlFetchApp.fetch(url + "cards/" + id_card + "/customField/" + id_cfield + 
"/item?&" + key_and_tokenoptions);
( Ive ommited the IDs but i think its clear how this works )
TAGS
AUG Leaders

Atlassian Community Events