Create new contact if not found in xero

Hi all,

I hope this is an easy one.

i have an sql query that triggers, essentially creating an invoice in xero.

All works well until i have a new venue, that isn’t currently in xero. and then of course it fails.

Is there a way of getting make to create one? i wondered if i should use a filter, and where the contactid or name doesn’t exist then create one. but i haven’t had much luck.

could anyone point me in the right direction please .

many thanks
ian

That’s what the error directive Resume allows you to do. First, you use a Search module to see if it exists, then Create a new item if it doesn’t exist. In the Create field, you use an if-statement to “ignore” a required field if there are search results, throwing an error and allowing you to “skip” the creation module.

Here, in this example, I’m using Notion, but you can apply the same concept to any integration that has a Search module.

The if (not-exist-create-ignore) throws the error (ignore if exists), which the Resume directive can be used to return the item from the Search module (to check if it exists).

Screenshot_2023-12-30_141250

I explained this in a similar older post Can I skip a module based on a filter? - #3 by samliew, Skipping a step/module - #8 by samliew

2 Likes

hi Sam

Many thanks for your help.

Before I can even test it, I need to wait for the SQL to come up with a new venue first, unless there is a way around that?

but to be clear is the ‘create if no result’ module a router module?

thanks
ian

Usually we do not use “Run an SQL statement” as the trigger module.

No, there are no routers.

One path is the normal path, and the hollow-dotted path is the error route. If you see the second link above it will be clearer.

3 Likes

Hi Sam

Nearly all my triggers are sql related.
Also the Xero Modules work differently to the Notion ones.

So there isn’t an error route for the Search for Contact in Xero or the Get contact in Xero.

So I am at a loss as to what to do.

Does anyone have any experience of what i can do in XERO? It is very simple i think.

If when a scenario searches for a contact and it doesn’t find one, then it creates a new one.

Thank you.
Ian

Just in case anyone follows this thread at a later date, I found the answer.

After the trigger happens, i do a Search Xero module. Which comes up empty if the contact doesnt exist. But then I add a router with two paths. 1 filters where the condition is:

Basic Operators: Exists

If this condition isn’t met, then the other path is taken, where it creates a new Contact.

Thanks
Ian

4 Likes

Hi @Ian_Kerry

I just want to quickly say congrats on getting this up and running :clap:

Thanks a lot for stepping back in here and sharing your final solution for the benefit of the community. This is much, much appreciated :pray:

2 Likes