Thursday
Hi everyone,
I'm building a custom connector for Salesforce and have implemented a 'Create Account' action. However, it’s not working as expected. Here's my setup:
Connection Details:
Action Code for 'Create Account':
Observed Issue:
The action fails when executed. It either returns an '302 not found'error.
Questions:
Any insights or suggestions are greatly appreciated! Thanks in advance.
SDK Console Code:-
{
title: 'Salesforce Connector',
connection: {
fields: [
{ name: 'client_id', optional: false },
{ name: 'client_secret', optional: false, control_type: 'password' }
],
authorization: {
type: 'oauth2',
authorization_url: lambda do |connection|
client_id = connection['client_id']
redirect_uri = "https://www.workato.com/oauth/callback"
scope = "full"
"https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=#{client_id}&red...}"
end,
token_url: lambda do |_connection|
"https://login.salesforce.com/services/oauth2/token"
end,
client_id: lambda do |connection|
connection['client_id']
end,
client_secret: lambda do |connection|
connection['client_secret']
end,
apply: lambda do |connection, access_token|
headers("Authorization": "Bearer #{access_token}")
end,
refresh_on: [401, 403],
refresh: lambda do |connection, refresh_token|
response = post("https://login.salesforce.com/services/oauth2/token")
.payload(
grant_type: "refresh_token",
client_id: connection['client_id'],
client_secret: connection['client_secret'],
refresh_token: refresh_token
)
{
access_token: response['access_token'],
refresh_token: response['refresh_token']
}
end
},
base_uri: lambda do |connection|
'https://curious-otter-480hm5-dev-ed.trailblaze.lightning.force.com/'
end
},
test: lambda do |_connection|
get("/services/data/v57.0/sobjects/Account/")
end,
actions: {
fetch_account: {
description: 'Fetch Salesforce Account',
input_fields: ->(_object_definitions) {
[
{ name: 'account_id', type: 'string', optional: false }
]
},
execute: lambda do |connection, input|
get("#{connection['base_uri']}/services/data/v62.0/sobjects/Account/#{input['account_id']}")
end,
output_fields: ->(_object_definitions) {
[
{ name: 'Id', type: 'string' },
{ name: 'Name', type: 'string' },
{ name: 'Phone', type: 'string' }
]
}
},
create_account: {
description: 'Create Salesforce Account',
input_fields: ->(_object_definitions) {
[
{ name: 'Name', type: 'string', optional: false },
{ name: 'Phone', type: 'string', optional: true }
]
},
execute: lambda do |connection, input|
post("#{connection['base_uri']}/services/data/v62.0/sobjects/Account/")
.payload(
Name: input['account_name'],
Phone: input['phone']
)
end,
output_fields: ->(_object_definitions) {
[
{ name: 'Id', type: 'string' },
{ name: 'Name', type: 'string' }
]
}
}
}
}