Google Contacts - Updtate Contact

:bullseye: What is your goal?

To update a contact’s phone number and email address.

:thinking: What is the problem & what have you tried?

When attempting to update the phone number and email address, MAKE does not accept the parameters:

BundleValidationError
Validation failed for 2 parameter(s).
Array of objects expected in parameter ‘emailAddresses’.
Array of objects expected in parameter ‘phoneNumbers’.

I have tried several ways. I check the size of the phone and email array first and only save to existing ones. I also used the formula with conditions to update [1] or [2] if they exist, or save directly if they don’t. Today there are several routes depending on the configuration of the phone and email array, but if the expression with the conditions works, it will be just one route and make everything simpler.

Here is the simple instruction confirming that the flow is filtered to come to this function if the array length is equal to 2. I also made sure that the phones are correct in the contents of the variables {{39.Tel_Celular_Tratado2}} and {{6.Tel_Empresa2_Parse}}

[
{ “metadata”: {{14.phoneNumbers[1].metadata}}, “value”: “{{39.Tel_Celular_Tratado2}}”, “type”: “mobile” },
{ “metadata”: {{14.phoneNumbers[2].metadata}}, “value”: “{{6.Tel_Empresa2_Parse}}”, ‘type’: “work” }
]

Here is the conditional flow to check if collections [1] and [2] exist:

]
{
{{if(14.phoneNumbers[1].metadata; ‘“metadata”: ’ & 14.phoneNumbers[1].metadata & ’; '; ‘’)}}
“value”: “{{39.Tel_Celular_Tratado2}}”;
“type”: “mobile”
};
{
{{if(14.phoneNumbers[2].metadata; ‘“metadata”: ’ & 14.phoneNumbers[2].metadata & ’; '; ‘’)}}
“value”: “{{6.Tel_Empresa2_Parse}}”;
“type”: “work”
}
]

To resolve this for now, I am deleting the existing Contact ID and recreating the contact with the phone numbers and emails I want to save, but obviously this is not ideal.

:clipboard: Error messages or input/output bundles

BundleValidationError
Validation failed for 2 parameter(s).
Array of objects expected in parameter ‘emailAddresses’.
Array of objects expected in parameter ‘phoneNumbers’.


:bullseye: What is your goal?

Fazer o updade do número de telefone e do email de um contato.

:thinking: What is the problem & what have you tried?

Na tentativa de fazer o update do telefone e do email, o MAKE não aceita os parâmetros:

BundleValidationError
Validation failed for 2 parameter(s).
Array of objects expected in parameter ‘emailAddresses’.
Array of objects expected in parameter ‘phoneNumbers’.

Eu já tentei de várias formas. Verifico antes o tamanho do array do telefone e do email e gravo apenas nos existentes e também usei a fórmula com condições para fazer o updtate em [1] ou [2] se existir ou gravar de forma direta caso não exista. Hoje há várias rotas conforme a configuração do arrya de telefone e email, mas se a expressão com as condicioinais funcionar, será apenas uma rota e tornará tudo mais simples.

Segue a instrução simples ratificando que o fluxo está filtrado para vir para essa função se o comprimento do array for igual a 2. Também me certifiquei que os telefones estão corretos nos conteúdos das variáveis {{39.Tel_Celular_Tratado2}} e {{6.Tel_Empresa2_Parse}}

[
{ “metadata”: {{14.phoneNumbers[1].metadata}}, “value”: “{{39.Tel_Celular_Tratado2}}”, “type”: “mobile” },
{ “metadata”: {{14.phoneNumbers[2].metadata}}, “value”: “{{6.Tel_Empresa2_Parse}}”, “type”: “work” }
]

Segue o fluxo condicional para verificar se o collection [1] e [2] existem:

[
{
{{if(14.phoneNumbers[1].metadata; '“metadata”: ’ & 14.phoneNumbers[1].metadata & '; '; ‘’)}}
“value”: “{{39.Tel_Celular_Tratado2}}”;
“type”: “mobile”
};
{
{{if(14.phoneNumbers[2].metadata; '“metadata”: ’ & 14.phoneNumbers[2].metadata & '; '; ‘’)}}
“value”: “{{6.Tel_Empresa2_Parse}}”;
“type”: “work”
}
]

Para resolver isso por enquanto estou excluindo o Contact ID existente e criando novamente o contato com os telefones e emails que quero gravar, mas logicamente não é o ideal

:clipboard: Error messages or input/output bundles

BundleValidationError
Validation failed for 2 parameter(s).
Array of objects expected in parameter ‘emailAddresses’.
Array of objects expected in parameter ‘phoneNumbers’.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

You cannot use JSON strings directly in array fields when “Map” is ON.

1. You can use the JSON “Parse JSON” module to convert a JSON string into an Array of Collections.

2. See “Mapping a Complex (Collection) Structure Into an Array Field” below for another option.

Combining Bundles Using Aggregators

Every result/item from some module types (like Trigger / Iterator / List / Search / Match modules) can potentially and likely output more than one bundle. These multiple bundles will individually run subsequent modules once per bundle, which is not optimal in most cases:

  • one operation per bundle per module, which could lead to…
  • use of multiple credits per bundle per module (some modules use more than one credit)
View example screenshots

Aggregator Example

The “Search Rows” module runs one time, returning 999 results (999 bundles).

  • Without Aggregator: the tools module run 999 times (999 operations)


    (and if there are more modules, they run 999 times each)

  • With Aggregator: the tools module only runs 1 time (1 operation)

:warning: Warning: :police_car_light:
This can easily use your entire quota of credits if you are not careful or fail to understand this concept.

To “combine” multiple bundles into a single variable, so that you can process all of the items in a single operation, you’ll need to use an aggregator. Aggregators is a type of module that accumulates bundles and outputs one bundle (unless you are using “Group By”). An example of a commonly-used aggregator module is the Array aggregator module.

You can find out more about some other aggregator modules here:

Question: Which is the best aggregator do you think you’ll need for your use-case?

Mapping a Complex (Collection) Structure Into an Array Field

The Array Aggregator module is very powerful because it allows you to build a new complex array of collections that matches a later module’s array field to map multiple items (collections) to it. Such fields initially may allow you to manually add individual items, but toggle the “Map” switch on, and you can map an array variable (from an Array Aggregator) containing multiple collections.

Simply select the respective “Target structure type” in an Array Aggregator module.

As you can see from the above example, the “Map” toggle on complex fields are used when you have an array variable (like from an array aggregator).

:clipboard: Note: :light_bulb:
Other combinations of modules may also allow you to generate an array that matches a future module field’s array structure, like “Aggregate to JSON + Parse JSON”, or “Create JSON + Parse JSON”, but this is an advanced topic.

Question: Are you mapping your array into a field that accepts more than one item/collection?

For more information, see “Mapping with arrays” in the Help Centre. You should also do the Make Academy, which also covers the use of Iterators & Aggregators.

Hope this helps! If you are still having trouble, please provide more details.

@samliew

:us_outlying_islands: Okay @samliew, I understand. I will look into it and try to resolve it.
Thanks for the quick message.
Best regards,
Pugliesi

Ok @samliew, entendi. Vou estudar e tentar solucionar.
Obrigado pela rápida mensagem.
Abraços
Pugliesi

:us: If you can help me with another issue, but within the same module, I am having an intermittent problem. In some cases, the Google Contacts - Search Contacts module has returned an empty response when there is actually a record in Google Contacts. When this happens, I run it again and the response is positive, that is, it returns the record for the searched item, but it has also happened that I ran it again and the response was negative, and on the third time the response was positive. Logically, this creates duplicate records.


Se puder me ajudar em outra questão, mas dentro do mesmo módulo, estou tendo um problema intermitente. Em alguns casos o módulo Google Contacts - Search Contacts tem trazido uma resposta vazia quando na verdade existe o registro em Google Contacts. Quando isso acontece, eu rodo novamente e a resposta é positiva, isto é, traz o registro do item pesquisado, mas aconteceu também de eu rodar novamente e a resposta ser negativa e na terceira vez a resposta é positiva. Logicamente que isso vair criando registros duplicados.

Alguma ação que eu possa fazer?

Try removing the “+” in front of the search query.

Please paste the output bundle of Sheets module, and input bundle of Contacts module here so I can see the variable types.


Please provide the input/output bundles of each of the relevant modules by running the scenario, or get the bundles from a previous run from the Scenario “History” tab.

Providing the bundles from a scenario run will allow others to replicate what is going on, especially if there are complex data structures (nested arrays and collections) and external services. This helps mapping the correct raw variable names from collections (instead of the label/display name).

Need help❓View instructions ◀

Click on the white speech bubbles on the top-right of each module and select “Download output (or input) bundles”.

A. Upload a Text File

Save each bundle contents in a plain text editor as a moduleNumber-output.txt file. Open the file to check if it has not added additional formatting or encoded the plain text.

  • You can upload files and images to this forum by clicking on the upload button:

    Uploading an attachment here will look like this:
    module1-input.txt (1.2 KB)
    module1-output.txt (3.4 KB)

B. Insert a Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the bundles AND format them correctly.

:warning: Formatting IS Important! :warning:

Here are some ways to provide text content in a way that it won’t be modified by the forum.

  • Method 1: Type code fence manually
    Manually type three backticks ``` in a separate line before and after the content, like this,

    ```
    text goes here
    ```
    
  • Method 2: Highlight the pasted content, then click the preformatted text/code button

  • Method 3: Upload your file elsewhere and share the public link
    This method is only advised for large files exceeding the forum upload limit.

This will allow others to better assist you. Thanks!

@samliew