Skip to main content

I’ve got a bit stuck with this one in GraphQL.

Background:

I want to update a card which has a required connectionField (you need to create a new card, not link to an existing one). This ConnectionField is to a Pipe, where the start form has some required fields.

GraphQL:

I’ve been looking at using updateFieldsValues to achieve this, but don’t find how to:

  1. Update the conneciton field - which is equal to adding a new card via this connection field
  2. Filling in the required fields in this new card (so that it successfully is created)

Appreciate any pointers or direction on this. If I haven’t made it clear enough please let me know, and I’ll improve the explanation.

Hello, how are you? In this case the creation would be of a connected card? If so, please try using this querry and tell me if it was possible?

mutation {

createCard(

input: {pipe_id: 302484445, fields_attributes: [{field_id: "test_api", field_value: [450307915]}, {field_id: "test_2", field_value: "hi2"}, {field_id: "task_title", field_value: "ball"}]}

) {

clientMutationId

}

}


Hi @natalia-manffre 

Thanks for this. So it looks like you’re saying this can be approached differently.

  • Step 1: Create the new card (with the code you pasted)
  • Step 2: Connect the new card created to the connected field

Did I understand you correctly?

I ask because currently this Pipe only allows the creation of cards from the connected field - not search and attach. So I don’t think that will work with this current set up.


In my memory, it indeed does not matter: you can use the createCard mutation, the createCardRelation mutation and/or the update field(s/values) mutation to connect the two cards. The “only allows the creation of cards from the connected field - not search and attach” restriction is just a front-end restriction to my knowledge.

In case it changes (changed?) some day, I would recommend to look at the queries Pipefy does using the Network tab in the developer console of your browser. There, when you enact the desired sequency of actions (i.e., create the connected card, update the field), you could see what series of queries is necessary to achieve your goal.


Thanks @genietim 

Working on it/ will let you know how it goes.


Hi @Keto-Faster  after the answer from @genietim  did it work for you this API?


Hi @natalia-manffre @genietim 

Unfortunately I have not been able to create cards with attached fields - I am getting errors. So I resorted to removing the ‘required’ on the connection fields for testing and linking them with createCardRelation afterwards, however, am still running into trouble.

Example Error

Error 30003 Validation failed: Source Source Field is not connected to repo 302727453

This is the GraphQL

mutation {

createCardRelation(

input: {
childId: ID,  // the child id is added here
parentId: ID, // the parent ID is added here
sourceId: 344416146,  // the internal field id is added here
sourceType: "Field"
       }

) {


clientMutationId

}

}

Not sure where this is going wrong. Would appreciate any thoughts.


The error indicates that the child was created in a pipe/table that is not the one connected to the field.

Not sure how to help here - either I’d have to ask for more exact details about your setup, or just again recommend to look into the network tab in the browser to see what queries Pipefy does exactly, maybe you find a difference between some repo or sourceId or something there (as, admittedly, they seem to be using slightly different mutations for certain things). See screenshot below.

 

 


Ok, good news @genietim. Thanks for your help.

I got past everything and it went through. The connection shows up in Pipefy now, BUT… it doesn’t show on the ConnectedField. It shows at the top left of the card that the connection is established, but it isn’t on the field.

I’m not sure how this is working @natalia-manffre perhaps you have an idea here, as I specified the internal id of the specific field and that it should connect at the Field level? 

This Creates the Card

This Relates the Card to that Card

mutation {

createCardRelation(

input: {
childId: {{180.id}},
parentId: {{81.id}},
sourceId: 344416146,
sourceType: "Field"
       }

) {


clientMutationId

}

}

 

Screenshot - you can see that “CRITERIA SET” has nothing connected to it. But the card “Company” is connected to this Card in “CRITERIA SET”.

 


Have you tried to set the connected card explicitly with the updateCardField or updateFieldsValues, respectively?

e.g.
 

mutation {

updateCardField (input {

card_id: theParentCardId,

field_id: theFieldIdButNotTheInternalOne,

new_value: theIdOfTheCardToConnect ]

}) {

clientMutationId

}

}

 


That got it @genietim - I used the updateCardField - thanks!

So I’ve got it working without the ‘required’ attribute on for the Connection Field now. That’ll be fine for the moment, can figure out how necessary required is/ and if there is a workaround for it.

So the full approach was:

  1. Create Child Cards First (createCard)
  2. Add to Parent Card with updateCardField Last

What error do you get with your – now working – approach when you reinstantiate the required attribute?

Respectively, no, I think I just understand now where you have a required attribute, shoudn’t you just set the connected field’s value when creating the parent card to the “

  theIdOfTheCardToConnect ]

”, instead of only afterwards with the updateCardField?


Reply