Skip to main content

I have the same problem, I’m trying to change to the new settings, but that’s not what I can do, can anyone help?


const mondayClient = initMondayClient();
mondayClient.setToken(token);
console.log ('Item ID:', itemId);
// Query 1 to get optvalue
const query1 = `query($itemId: ID, $typeColumnId:String, $statusId: String) {
items(ids: d$ID]) {
column_values(ids: d$typeColumnId, $statusId]) {
value
}
}
}
`;

//const query1 = `query($itemId: IInt], $typeColumnId: String, $statusId: String) { items(ids: $itemId) { column_values(ids: d$typeColumnId, $statusId]) { text } } }`;

const variables1 = { typeColumnId, boardId, itemId, statusId, textValue };
console.log ('variables1',variables1);

with this error


variables1 {

2023-10-24T15:01:43.795051643Z typeColumnId: 'opportunity_id',

2023-10-24T15:01:43.795055843Z boardId: 5341381563,

2023-10-24T15:01:43.795059243Z itemId: 5383449058,

2023-10-24T15:01:43.795062443Z statusId: 'status6',

2023-10-24T15:01:43.795065743Z textValue: 'Opportunity'

2023-10-24T15:01:43.795068943Z }

2023-10-24T15:01:44.009073037Z response1 {

2023-10-24T15:01:44.009146539Z errors: r

2023-10-24T15:01:44.009152239Z {

2023-10-24T15:01:44.009155939Z message: 'Variable $itemId is declared by anonymous query but not used',

2023-10-24T15:01:44.009159439Z locations: nArray],

2023-10-24T15:01:44.009162739Z path: tArray],

2023-10-24T15:01:44.009165939Z extensions: nObject]

2023-10-24T15:01:44.009169139Z },

2023-10-24T15:01:44.009172039Z {

2023-10-24T15:01:44.009175139Z message: 'Variable $ID is used by anonymous query but not declared',

2023-10-24T15:01:44.009178339Z locations: nArray],

2023-10-24T15:01:44.009181539Z path: tArray],

2023-10-24T15:01:44.009184739Z extensions: nObject]

2023-10-24T15:01:44.009187939Z }

2023-10-24T15:01:44.009191139Z ],

2023-10-24T15:01:44.009194239Z account_id: 4811106

2023-10-24T15:01:44.009197339Z }

2023-10-24T15:01:44.018460782Z TypeError: Cannot read properties of undefined (reading 'items')

Can you help?


Thank you

The error message specifically says Variable $itemId is declared but not used and Variable $ID is used but not declared. Check your usage around these two variables and their declarations to find your solution.


I have this function, with the same structure, and it works


const getDatesValue = async (token, itemId, startColumnId, endColumnId) => {
// Used in Dates To timeline
try {
const mondayClient = initMondayClient();
mondayClient.setToken(token);

const query = `query($itemId: ID, $startColumnId: String, $endColumnId: String) {
items(ids: [$itemId]) {
column_values(ids: [$startColumnId, $endColumnId]) {
value
}
}
}
`;
const variables = { startColumnId, endColumnId, itemId };

const response = await mondayClient.api(query, { variables });
console.log ('response timeline:', response);
if (response.data.items[0].column_values[0].value !== null && response.data.items[0].column_values[1].value !== null) {
return response;
}
} catch (err) {
console.error(err);
}
};

Thats why i can’t undersant why this one doens’t work


I refactored the function that works, and I still have problems


new function:


const objectRelation = async (token, typeColumnId, boardId, itemId, statusId, textValue) => {
// test
try {
const mondayClient = initMondayClient();
mondayClient.setToken(token);

const query = `query($itemId: ID, $typeColumnId: String, $statusId: String) {
items(ids: [$itemId]) {
column_values(ids: [$typeColumnId, $statusId]) {
value
}
}
}
`;
const variables = { typeColumnId, statusId, itemId };
console.log ('variables:', variables);
const response = await mondayClient.api(query, { variables });
console.log ('response:', response);
if (response.data.items[0].column_values[0].value !== null && response.data.items[0].column_values[1].value !== null) {
return response;
}
} catch (err) {
console.error(err);
}
};

with this error


023-10-24T16:28:49.761416818Z variables: {

2023-10-24T16:28:49.761499919Z typeColumnId: 'opportunity_id',

2023-10-24T16:28:49.761505919Z statusId: 'status6',

2023-10-24T16:28:49.761509419Z itemId: 5384299179

2023-10-24T16:28:49.761512519Z }

2023-10-24T16:28:49.957770970Z response: {

2023-10-24T16:28:49.957878071Z errors: [

2023-10-24T16:28:49.957882872Z {

2023-10-24T16:28:49.957886372Z message: 'Type mismatch on variable $itemId and argument ids ([id]! / [Int])',

2023-10-24T16:28:49.957889772Z locations: [Array],

2023-10-24T16:28:49.957892972Z path: [Array],

2023-10-24T16:28:49.957896172Z extensions: [Object]

2023-10-24T16:28:49.957899572Z }

2023-10-24T16:28:49.957902872Z ],

2023-10-24T16:28:49.957905972Z account_id: 4811106

2023-10-24T16:28:49.957914572Z }

Hello there @fabiomiguel.ribeiro,


If you want to send your full script + the response you get to appsupport@monday.com, we can take a look from there 😁


Looking forward to hearing from you via email!


Cheers,

Matias


I tried to create a new app, based on what’s on github, however I’m getting this error


image


Hello there @fabiomiguel.ribeiro,


It looks like that error is not coming from monday but might be related to your environment.


I found these links that might be useful here:


github.com/bugsnag/bugsnag-js

If you can not find a solution here, please send us an email to appsupport@monday.com and we will try to help with it 😁


Cheers,

Matias


Reply