Solved

Getting Start Form details of a card

  • 10 February 2023
  • 6 replies
  • 279 views

Userlevel 2
Badge

Hi, I am trying to get Start Form values of a particular card(by id). I can get basic details of the card by using the following query
 

{
"query": "{card(id: 595234678) {title done id updated_at }}"
}

But it does not fetch the start form details (excluding the reason that i have not mentioned its field which i could not find)

Can you please help me with a query which queries the start from details of the card as well please?
@genietim I humbly request you to help me with this.

icon

Best answer by genietim 10 February 2023, 17:15

View original

6 replies

Userlevel 7
Badge +12

Thanks!

So, what you are currently querying is this: https://api-docs.pipefy.com/reference/objects/Card/

And when you look there, you can find the attribute `fields`, that you want to query.

That makes your query look like this:

query {
card(id: 638121829) {
title done id updated_at

fields { name array_value value field { id internal_id type } }
}
}

Note that instead of only “fields”, I also added what values you might want to have of the field: the name of the field, its value, and also the id and its type.

You find out how these parts of the query are called when you click on the “CardField” link in the documentation listed above right next to the attribute “fields” that I hinted at above.

If you now also need to know for each field, what phase it comes from, you have to go even a level deeper: notice the “phase_field” attribute, and therein the attribute “phase”, which will help you separte the fields from the start form from the fields in the other phases in your code.

Therefore, a final query could look like this:

query {
card(id: 638121829) {
title done id updated_at

fields { name array_value value field { id internal_id type }
phase_field { id index_name label phase { id index name } }
}
}
}

(where, again, I made some selection of other attributes you could be interested in. You might find others in the documentation)

In your code, you would then have to filter the card’s fields based on the phase_field → phase → name property to be == “Start form”. Or, if you have another phase you also named “Start form”, you can use the phase_field → phase → index property to be == 0.0.

Userlevel 7

Hi @wf-suchit-gupta, hope you are fine!
You can use this query to get value from a specific card:

{  card(id: 2712489) {    title    assignees {      id    }    comments {      text    }    comments_count    current_phase {      name    }    done    due_date    fields {      name      value    }    labels {      name    }    phases_history {      phase {        name      }      firstTimeIn      lastTimeOut    }    url  }}
 
Userlevel 7
Badge +12

With your answer, @Lais Laudari , how would you suggest they could distinguish between fields on the start form and fields elsewhere (except for manually filtering them, knowing which name the fields on the start form have)?

Userlevel 7

@genietim Im checking a way to do that and I will be back to you soon!😉

Userlevel 7
Badge +12

I mean, if you are ok with the “filtering in your code” I proposed in my answer, you can simply adjust your query to either include the fields → phase_field → phase → index fields, e.g., or add on your phase_history the phase → fields → index & name fields.

Userlevel 7

You are right @genietim!
Your proposal are the best way, I was justing lookinkg for the query ready to use.

@wf-suchit-gupta do you get what you need?

Reply