Handling missing variables from a Webhook call
I am integrating Xano with Salesforce. I've gotten it to work fairly well but when data isn't populated in Salesforce the API callout doesn't include a null value for the variable but rather just strips it from the call.
An example is Middle Name. When it is populated in Salesforce the JSON looks like this:
{
"new":
[
{
"Id": "00QAd000007uz1ZLAQ",
"LastName": "Johnson",
"FirstName": "Joe",
"LeadSource": "Trade Show",
"MiddleName": "Bob",
"Salutation": "Mr.",
},
],
"old":
[
{
}
],
"userId": "0054K000001cmRSQAY"
}
When it isn't populated it looks like this:
{
"new":
[
{
"Id": "00QAd000007uz1ZMAQ",
"LastName": "Johnson",
"FirstName": "Joe",
"LeadSource": "Trade Show",
"Salutation": "Mr.",
},
],
"old":
[
{
}
],
"userId": "0054K000001cmROQAY"
}
When Xano gets the second JSON there is a 500 error with the message: Unable to locate var: fromSalesforce.new.0.MiddleName
Is there a way to handle missing input variables like this somehow? I've tried checking for null but that seems to only check for a null value and not a missing variable.
Best Answer
-
Hi @orn - you can use the GET filter (https://docs.xano.com/working-with-data/dot-notation#get-filter) instead of dot notation. This filter will let you define a default value such as null or an empty string when the middle name is not present in the payload.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback