I am creating custom action. I want when this custom action to send an api call to my platform which will return a “Included” or “Excluded” response and based on the response of api, If it’s “Include” then it 4 string type fields should be visible on my action form else those 4 fields should not bbe visible on the action form.
I tried like following but it is not working the way I want because it is including select dropdown. I don’t want user to select any field and then 4 fields should be visible on the action form.
I want my api to be called silently which will return “Included” or “Excluded” and based on that api response 4 fields to be shown or not in the action form. Thank you in advance.
I tried followng code
return {
actionUrl: ‘https://webhook.site/d4acb54d-e210-4d04-b0e4-7d42351f3ddb’,
published: true,
objectTypes: [‘CONTACT’],
inputFields: [
{
typeDefinition: {
name: ‘selectTemplate’,
type: ‘enumeration’,
fieldType: ‘select’,
optionsUrl: `${backendUrl}/template/postCardOptions`,
dynamicOptions: true
},
supportedValueTypes: [‘STATIC_VALUE’],
isRequired: true
},
{
typeDefinition: {
name: “propertyAddress”,
type: “string”,
fieldType: “text”
},
supportedValueTypes: [“STATIC_VALUE”],
isRequired: false
},
{
typeDefinition: {
name: “propertyCity”,
type: “string”,
fieldType: “text”
},
supportedValueTypes: [“STATIC_VALUE”],
isRequired: false
},
{
typeDefinition: {
name: “propertyState”,
type: “string”,
fieldType: “text”
},
supportedValueTypes: [“STATIC_VALUE”],
isRequired: false
},
{
typeDefinition: {
name: “propertyZipCode”,
type: “string”,
fieldType: “text”
},
supportedValueTypes: [“STATIC_VALUE”],
isRequired: false
}
],
outputFields: [
{
typeDefinition: {
name: ‘myOutput’,
type: ‘string’,
fieldType: ‘text’
},
supportedValueTypes: [‘STATIC_VALUE’]
}
],
inputFieldDependencies: [
{
dependencyType: “SINGLE_FIELD”,
controllingFieldName: “selectTemplate”,
dependentFieldNames: [
“propertyAddress”,
“propertyCity”,
“propertyState”,
“propertyZipCode”
]
}
],
labels: {
en: {
inputFieldLabels: {
selectTemplate: “Select Template”,
propertyAddress: “Property Address”,
propertyCity: “Property City”,
propertyState: “Property State”,
propertyZipCode: “Property Zip Code”
},
actionName: “My Extension”,
actionDescription: “My Extension Description”,
appDisplayName: “My App Display Name”,
actionCardContent: “My Action Card Content”
}
},
functions: [
{
functionType: “PRE_ACTION_EXECUTION”,
functionSource: `exports.main = async (event, callback) => {
try {
const includeFields = true;
const inputFields = {
propertyAddress: includeFields ? ‘’ : null,
propertyCity: includeFields ? ‘’ : null,
propertyState: includeFields ? ‘’ : null,
propertyZipCode: includeFields ? ‘’ : null,
};
callback({ inputFields });
} catch (error) {
console.error(“Error in PRE_ACTION_EXECUTION function:”, error);
callback({ error: ‘Failed to execute pre-action function’ });
}
}`
}
]
};