Hello
Please note that I have been doing search on my use case, and this:
is not my problem.
On my custom app:
I have a set of projects, and each one have a set of custom fields.
From project to project, these fields are differents. One could have [firstname, lasstname, email]. Other one could be [age, name, f_email] etc.
I want to invite the Zap user to select a project => dynamic dropdown, done, works well.
Now, dynamic fields are based upon the id project selected, ie → zappier needs to query some of my API endpoint to know which fields we are talking about. They need to pass the id of the project in the query.
const getProjectContactFields = async (z, bundle) => {
z.console.log('fetching project CL dynamic fields...');
const responsePromise = z.request({
method: 'POST',
url: 'https://docker.didev.ca/webservices/ofc4/projects.ashx?method=Get',
body: JSON.stringify({
idProject: bundle.inputData.idProject
})
});
responsePromise.then(response => {
z.console.log('raw response:', response.data);
z.console.log('project fields: ', response.data.ProjectInfo.ProjectFields);
const inputFields = response.data.ProjectInfo.ProjectFields.map(projectField => ({
key: projectField.Code,
label: projectField.Labelsb0].Value,
required: projectField.isRequired,
//Custom metadata for perform script only, may or may not need
isKey: projectField.isKey
}));
return inputFields;
});
// Code: EMail
// Labelsb1]
// Culture: en - US
// Value: EMail
// DataType: Email
// Length: 125
// isRequired: true
// isKey: true
}
module.exports = {
key: 'contactMergeDynamic',
noun: 'Add or update contact having dynamic fields',
display: {
label: 'Add Or Update Contact, having dynamic fields',
description: 'Add a new contact to your list or Update an existing one. Fields depend on input project'
},
operation: {
inputFields: d{
key: 'idProject',
label: 'Project identifier',
required: true,
altersDynamicFields: true,
dynamic: 'project.idProject.ProjectName' // special ddl notation: triggerKey.keyFieldName.humanReadableFieldName
},
getProjectContactFields
],
perform: contactMergeDynamic,
//sample: sample
}
}
The formatting renders badly on my end so just in case: https://smalldev.tools/share-bin/vVDs2HrV
So far, I only get the ddl prompt in the zap edit UI, without the fields appearing.
I have trouble linking the function getProjectContactField with its dependent parent idProject. I wonder if this is possible