Hello,
I am trying to create a static lookup within the variable definition of a GraphQL flow. I create the lookup within the variables called "LookupName," and use the following handlebar syntax when trying to request the lookup to run:
"{{lookup 'LookupName' this.record.FieldID.value}}"
However, this returns some sort of code like this instead that is not a valid value defined in the lookup:
"$ASYNCID$0$11$"
and when I try to test run the flow itself, nothing is populated in the field that needs to be looked up. On top of this, there is no way to open and edit the existing Lookup that I created. everytime I open the Variables, there is only an option for "Create Lookup" - how do i modify an existing lookup, especially as business requirements grow or change??
@caseylassiter can you send some screenshots of your setup? I don't think the lookup handlebar expression will work here since it's pretty limited to just being used within the mapping steps on a flow imports/lookups. It sounds like we could potentially use form settings and/or scripts, but I don't fully get what you're trying to do with this lookup.
@tylerlamparter
Here is the full Variable in the Handlebars template. I created 'CatalogLookup2' within this screen, but as I was saying before there is no way to re-open 'CatalogLookup2' after you save and close the lookup screen:
The purpose of the lookup is the input has a variable called PriceClassID, that is normally something like 'NEWT3' or similar. I created the lookup so that it returns the corresponding URI that is needed for the software I am importing to (Which is Shopify. I'm using GraphQL because the Shopify endpoint is not yet supported in the out-of-the-box Shopify connector)
The create lookup screen looked something like this, but with more values:
@caseylassiter I'm checking internally on whether this is a bug or we have something setup wrong. In the meantime, there is another way we could do this with settings and scripts.
Under the settings tab for your integration (or flow, flow group, import, export step), you can make a key value pair setting that looks something like this:
Which has this JSON powering it under the "launch form builder" option there.
{
"fieldMap": {
"URItoPriceClassID": {
"id": "URItoPriceClassID",
"name": "URItoPriceClassID",
"type": "keyvalue",
"label": "URI to Price Class ID",
"keyName": "URI",
"valueName": "PriceClassID",
"showDelete": true
}
},
"layout": {
"fields": [
"URItoPriceClassID"
]
}
}
After we have the form built and mappings made, we can write a short little transform script to manipulate the data in the flow while referencing that form. In my example, I've built a transform script on the initial export step of the flow. You could do this on a presave script or premap script as well, but the script would have to be slightly modified to fit different contexts.
In the script, you can see the settings inputs on the right hand side and the script just simply takes the PriceClassId.value field, looks it up within the settings array, and returns the result. If no result is found, I have it throwing an error back.
function transform (options) {
let lookupResults = options.settings.integration.URItoPriceClassID.find(e => e.PriceClassID === options.record.PriceClassId.value);
if (lookupResults) {
options.record.PriceClassId.uri = lookupResults.URI;
} else {
throw("No lookup match found for " + options.record.PriceClassId.value + ". Please add a mapping under the settings for this integration.");
}
return options.record;
}
@caseylassiter we confirmed there are a few issues here. In the meantime I would suggest the alternative method I suggested.
Hey @tylerlamparter
I appreciate you looking into this. I don't see in our environment where to make a key value pair setting. I see in the developer playground where I can create and test the JSON example you gave, but how do I install it on the flow directly?
Thanks,
Casey
@caseylassiter it looks like you would need to enable developer mode under your profile settings. Here are the docs for that: https://connective.celigo.com/t/faq-what-s-in-developer-mode-for-me/1394.
@tylerlamparter you are the man! this did the trick!