Additional scope not working

Here my code js:

function addToBlackList() {
  if (ClientType.value === 'Individual') {
    getUserID.trigger({
      additionalScope: {
        email: ClientEmail.value.toLowerCase()
      },
      onSuccess: function(getUserIDResponse) {
        const userId = getUserIDResponse;

        add2BlackList.trigger({
          additionalScope: {
            userId: userId
          },
          onSuccess: function() {
            isBannedQuestion.trigger(); 
          },
          onFailure: function(error) {
            console.error("AddToBlackList Individual Error:", error);
          }
        });
      },
      onFailure: function(error) {
        console.error("getUserID Error:", error);
      }
    });
  } else if (ClientType.value === 'Business') {
    const companyId = CompanySelect.value;
    console.log('companyId',companyId)

    add2BlackList.trigger({
      additionalScope: {
        userId: companyId 
      },
      onSuccess: function() {
        isBannedQuestion.trigger(); 
      },
      onFailure: function(error) {
        console.error("AddToBlackList Business Error:", error);
      }
    });
  }
}

addToBlackList();

When I tried to start, I get error:


The additional area is empty, but as you can see in console.log the value is there

my query

Hey @Alex_Nazarenko,

You could try invoking it directly in the query without using the variables section.

↑
    id: {{ BankSelect.value }}
    bannedUsers : {{ userId }}
↓

This is how i've normaly got additional scope to work with GraphQL and other queries. The linting shows it in red sometimes, but it still works.

Thank you, but I don't understand how I can invoking directly in the query?
add2BlackList.trigger( ...

New problem ...


Why retool doesn't see my function

Ok, after some number of update page it is find my request. But still doesn't work



What is wrong?

On your GraphQL code for add2BlackList, replace lines 3 & 4 with the following:

    id: {{ bankId }}
    bannedUsers : {{ userId }}

and you could delete the two variables (bankId & userId) that you've defined below.

Same result