Question

Need help with actions and nested objects

  • 28 September 2023
  • 0 replies
  • 108 views

Hi, ive been trying for a very long time creating my first action for the test integration im building as a MVP.

I managed to setup authentication and triggers. But im stuck at atction :(

The user case. Something happen in salesforce, then zapier creates. a quote in the stystem

Unfortunately ive been stuck for a while on actions. I can't seem to figure out how the setup the input designer to allow for both Line items as well as nested objects. And it all stops when im trying to test the action.

This is the code i have in api conifg

 

const options = {
url: 'https://api.fastspring.com/quotes',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
'coupon': bundle.inputData.coupon,
'currency': bundle.inputData.currency,
'expirationDateDays': bundle.inputData.expirationDateDays,
'items': [{
'product': bundle.inputData.product,
'unitListPrice': bundle.inputData.unitListPrice,
'quantity': bundle.inputData.quantity
}],
'name': bundle.inputData.name,
'notes': bundle.inputData.notes,
'netTermsDays': bundle.inputData.netTermsDays,
'recipient': {
'company': bundle.inputData.company,
'email': bundle.inputData.email,
'first': bundle.inputData.first,
'last': bundle.inputData.last,
'phone': bundle.inputData.phone
},
'recipientAddress': {
'addressLine1': bundle.inputData.addressLine1,
'addressLine2': bundle.inputData.addressLine2,
'city': bundle.inputData.city,
'country': bundle.inputData.country,
'postalCode': bundle.inputData.postalCode,
'region': bundle.inputData.region
}
})
}

return z.request(options)
.then((response) => {
response.throwForStatus();
return response.json;
});


When i move on to test, i can see recipient and recipient adress object. I tried different ways but it always errors me out, either big error alert or it tells me some test data is missing, When i switch to raw on testing it, this is the code i have

 

{
"inputData": {
"coupon": "TENOFF",
"currency": "USD",
"expirationDateDays": "30",
"items": "[object Object]",
"name": "Quote for ABC Company22111",
"notes": "",
"netTermsDays": "",
"recipient": {
"company": "",
"email": "fred@linfjard.com",
"first": "Fred",
"last": "Linfjard",
"phone": ""
},
"addressLine1": "",
"addressLine2": "",
"city": "",
"country": "",
"postalCode": "",
"region": ""
}
}

 As you can see, recipient does not list anything, and since wanted to try to put recipientadress field not in a line item, it looks like this.

Im completely cluesless and really need help. The action simply just need to execute this for a succesful post call

 

{
"coupon": "TENOFF",
"currency": "USD",
"expirationDateDays": 30,
"items": [
{
"product": "converzilla-monthly",
"unitListPrice": 0,
"quantity": 1
}
],
"name": "Quote for ABC Company22111",
"notes": "",
"netTermsDays": 0,
"recipientAddress": {
"addressLine1": "801 Garden St",
"addressLine2": "Suite 201",
"city": "Santa Barbara",
"country": "US",
"postalCode": "93101",
"region": "California"
},
"recipient": {
"company": "ABC Company",
"email": "ne1@all.com",
"first": "Leeroy",
"last": "Jenkins",
"phone": "+1254789654"
}
}

Super thanks ful


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.