Going Back a Step

Hi there,

I have a scenario that works well, and has a couple of routers on it, and various paths.

But after the first router I have added a new path which basically creates a new contact if there isn’t one.

But when it has created it, i would like it to go back to the first router perform it again and carry on - rather than me having to clone all those other paths.

Is this possible?

Thanks
Ian

Okay simply you have to do is
Modify your original scenario to accept contact data as input.
Use a Store Data module to store the created contacts ID details.
When calling the original scenario, pass this contact data as input.
Adjust your original scenario modules to use the passed data instead of recreating the contact.

3 Likes

Hi @Ian_Kerry,

@samliew recently described a good way to tackle this in another post if you want to check that out here.

Perhaps you could adapt for your case.

3 Likes

Hi tanish_1jain

I am not that experienced with make yet. so i found it hard to follow what you were saying.

i didnnt’ know how to get my scenario to accept “contact data” as input. what i did do though was to create a new venue in my sql so at least i had a venue to work with.

i couldn’t find a ‘store module’ either. i did search for one but no joy.

and i didn’t understand the rest of it i am afraid, but thank you for trying to help.

i originally wanted to know if there was a way of stepping back a step in a scenario.

as a work around i have just cloned all the other steps in my scenario, and added them to this branch of the scenario - but i would still like to know.
thanks

ian

Thanks @Donald_Mitchell i’ll check it out.

Hi @Donald_Mitchell

I think that I would need a bit more hand holding that the example that @samliew and yourself started. The Xero modules are slightly different. And I have never used the pink IGNORE command though i can see this could be very useful.

For instance, when my SQL triggers the scenario, the SEARCH FOR CONTACTS returns 0 bundles - so i assume the next module (or is it a filter) should have some code in it saying if{bundles=0} then create a new record in Xero, else skip the create new and continue?

thanks

ian

After Search for Contacts, you would add the Xero Create a Contact module.
Then, right click on Create a Contact, add error route, and select the Resume module.
The result should look something like this:

In Search a Contact, if it was successful, it would result in Total Number of Bundles > 0 (Internally, this field is called IMTLENGTH), a Contact ID and maybe other data about the contact.

In Create a Contact, fill in all the fields as you normally would as if you were creating a new contact, assuming one wasn’t found in the previous step.

The only difference here is you need to find a field that is required (where the field’s name is Bold) like maybe Name or First Name, and enter the formula:
if({{5.__IMTLENGTH__}}{{=}}0;Bob;{{ignore}})

Where 5 is the number of the Search for Contacts module and Bob is the value that would be used trying to create a new contact.

I don’t know if this would render correctly for you, but it’s saying this:
“if the number of bundles returned from Search Contacts is 0 (no results found), then use ‘Bob’, otherwise, use {{ignore}}, which will trigger an error and take the ‘Resume’ path”.
The Resume module takes the values you fill in the fields as substitutes those as the output for Create a Contact.

In the resume module, you fill in everything from Search Contacts module, at the very least the Contact ID that was found from the search.

Sorry if it’s more confusing now, but I hope it helps!

2 Likes

Thanks Donald, I have had great fun trying and learning thins for other scenarios.

I haven’t quite got this working. here is how far i have got:

so my sql triggers with a new venue:

image

with iantest1 being the name i will search for in Xero.

image

Search returns 0 bundles.

Then

image

then

but i have a feeling that now i still need to search for the contact as later it still fails because i havent searched and found the contact.

I ave to logoff now but will check this later.
thanks
ian

In your Resume module, instead of mapping 1. VENUE in the Name field, you need to map the name from Search for Contacts. All of the fields in the Resume module should map to whatever was output from the Search for Contacts.

2 Likes

Thanks again Donald.

Is there an error in the syntax here:

image

because i seem to have created a new contact in Xero called if(falseiantest1;)

:slight_smile:

thanks
ian

Sorry about that. If() should be a function, but didn’t convert correctly, possibly because I missed the double curly braces before “if”.
You can try removing the open parenthesis after “if” then typing In a new open parenthesis and it should convert to the function.
At the end of the line you can remove that close parenthesis and again re-add a closing parenthesis and it should close out the function.

2 Likes

Hi Donald,

I have spent a couple of hours trying all sorts of things to make this work, and all i have succedded in is making a whole load of new contacts in Xero, which apparently one can’t delete (thanks Xero).

i think i have the function correct:

image

but you will notice that the first blue part i have made it into number of bundles - i think this is the same as 5.IMTLENGHT ?

Despite being close, i feel i may have to give up on this one for now, it is just taking me too long!

But before I do. I think the logic is this.

Step 1 - search for a contact in Xero
Step 2 - if te number of bundles in Step 1 >0 then ignore this step, otherwise create a new contact?

Ah now following that logic… i have amended and it may have worked.

Step 2 - needs the name that it is going to create, so it needs to refer to the original sql query:
image

We will see if it works in the real world.

Thanks for all your help Donald.

Ian

Yep,

__IMTLENGTH__

is the same as total number of bundles.

You will need to surround the equal sign with curly braces like this: {{=}} so that it is treated as an operator instead of text.

2 Likes

Thanks Donald, again appreciated. Fingers crossed!

2 Likes

Really appreciated. I’ve been following this guide but having an issue forwarding the data from the search step to the create step. It seems that the bundle from create remains empty with a 422 error, while I was expecting it to change to 200 and update with the data from the search step. What am I missing? Also, I guess in downstream components I should point to the output from the create step as this is either populated with the created data or the search data results?

image