diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-case/fields.js b/packages/backend/src/apps/vtiger-crm/actions/create-case/fields.js new file mode 100644 index 00000000..ad497ac9 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-case/fields.js @@ -0,0 +1,408 @@ +export const fields = [ + { + label: 'Summary', + key: 'summary', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Record Currency', + key: 'recordCurrency', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listRecordCurrencies', + }, + ], + }, + }, + { + label: 'Case Title', + key: 'caseTitle', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Status', + key: 'status', + type: 'dropdown', + required: true, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.status', + value: 'casestatus', + }, + ], + }, + }, + { + label: 'Priority', + key: 'priority', + type: 'dropdown', + required: true, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.priority', + value: 'casepriority', + }, + ], + }, + }, + { + label: 'Contact Name', + key: 'contactName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContacts', + }, + ], + }, + }, + { + label: 'Organization Name', + key: 'organizationName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOrganizations', + }, + ], + }, + }, + { + label: 'Group', + key: 'group', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listGroups', + }, + ], + }, + }, + { + label: 'Assigned To', + key: 'assignedTo', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Product Name', + key: 'productName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listProducts', + }, + ], + }, + }, + { + label: 'Channel', + key: 'channel', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.channel', + value: 'casechannel', + }, + ], + }, + }, + { + label: 'Resolution', + key: 'resolution', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Category', + key: 'category', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.category', + value: 'impact_type', + }, + ], + }, + }, + { + label: 'Sub Category', + key: 'subCategory', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.subCategory', + value: 'impact_area', + }, + ], + }, + }, + { + label: 'Resolution Type', + key: 'resolutionType', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.resolutionType', + value: 'resolution_type', + }, + ], + }, + }, + { + label: 'Deferred Date', + key: 'deferredDate', + type: 'string', + required: false, + description: 'format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Service Contracts', + key: 'serviceContracts', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listServiceContracts', + }, + ], + }, + }, + { + label: 'Asset', + key: 'asset', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listAssets', + }, + ], + }, + }, + { + label: 'SLA Name', + key: 'slaName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listSlaNames', + }, + ], + }, + }, + { + label: 'Is Billable', + key: 'isBillable', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'True', value: '1' }, + { label: 'False', value: '-1' }, + ], + }, + { + label: 'Service', + key: 'service', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listServices', + }, + ], + }, + }, + { + label: 'Rate', + key: 'rate', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Service Type', + key: 'serviceType', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.serviceType', + value: 'servicetype', + }, + ], + }, + }, + { + label: 'Service Location', + key: 'serviceLocation', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCaseOptions', + }, + { + name: 'parameters.serviceLocation', + value: 'servicelocation', + }, + ], + }, + }, + { + label: 'Work Location', + key: 'workLocation', + type: 'string', + required: false, + description: '', + variables: true, + }, +]; diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-case/index.js b/packages/backend/src/apps/vtiger-crm/actions/create-case/index.js new file mode 100644 index 00000000..be770e7d --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-case/index.js @@ -0,0 +1,78 @@ +import defineAction from '../../../../helpers/define-action.js'; +import { fields } from './fields.js'; + +export default defineAction({ + name: 'Create case', + key: 'createCase', + description: 'Create a new case.', + arguments: fields, + + async run($) { + const { + summary, + recordCurrency, + caseTitle, + status, + priority, + contactName, + organizationName, + group, + assignedTo, + productName, + channel, + resolution, + category, + subCategory, + resolutionType, + deferredDate, + serviceContracts, + asset, + slaName, + isBillable, + service, + rate, + serviceType, + serviceLocation, + workLocation, + } = $.step.parameters; + + const elementData = { + description: summary, + record_currency_id: recordCurrency, + title: caseTitle, + casestatus: status, + casepriority: priority, + contact_id: contactName, + parent_id: organizationName, + group_id: group, + assigned_user_id: assignedTo, + product_id: productName, + casechannel: channel, + resolution: resolution, + impact_type: category, + impact_area: subCategory, + resolution_type: resolutionType, + deferred_date: deferredDate, + servicecontract_id: serviceContracts, + asset_id: asset, + slaid: slaName, + is_billable: isBillable, + billing_service: service, + rate: rate, + servicetype: serviceType, + servicelocation: serviceLocation, + work_location: workLocation, + }; + + const body = { + operation: 'create', + sessionName: $.auth.data.sessionName, + element: JSON.stringify(elementData), + elementType: 'Cases', + }; + + const response = await $.http.post('/webservice.php', body); + + $.setActionItem({ raw: response.data }); + }, +}); diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-contact/fields.js b/packages/backend/src/apps/vtiger-crm/actions/create-contact/fields.js new file mode 100644 index 00000000..b4b72e18 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-contact/fields.js @@ -0,0 +1,649 @@ +export const fields = [ + { + label: 'Salutation', + key: 'salutation', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'Mr.', value: 'Mr.' }, + { label: 'Ms.', value: 'Ms.' }, + { label: 'Mrs.', value: 'Mrs.' }, + { label: 'Dr.', value: 'Dr.' }, + { label: 'Prof.', value: 'Prof.' }, + ], + }, + { + label: 'First Name', + key: 'firstName', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Last Name', + key: 'lastName', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Primary Email', + key: 'primaryEmail', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Office Phone', + key: 'officePhone', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Mobile Phone', + key: 'mobilePhone', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Home Phone', + key: 'homePhone', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Date of Birth', + key: 'dateOfBirth', + type: 'string', + required: false, + description: 'format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Fax', + key: 'fax', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Organization Name', + key: 'organizationName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOrganizations', + }, + ], + }, + }, + { + label: 'Title', + key: 'title', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.title', + value: 'listContactOptions', + }, + ], + }, + }, + { + label: 'Department', + key: 'department', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Reports To', + key: 'reportsTo', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContacts', + }, + ], + }, + }, + { + label: 'Lead Source', + key: 'leadSource', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.leadSource', + value: 'leadsource', + }, + ], + }, + }, + { + label: 'Secondary Email', + key: 'secondaryEmail', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Assigned To', + key: 'assignedTo', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Do Not Call', + key: 'doNotCall', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'True', value: '1' }, + { label: 'False', value: '-1' }, + ], + }, + { + label: 'Notify Owner', + key: 'notifyOwner', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'True', value: '1' }, + { label: 'False', value: '-1' }, + ], + }, + { + label: 'Twitter Username', + key: 'twitterUsername', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'SLA Name', + key: 'slaName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listSlaNames', + }, + ], + }, + }, + { + label: 'Lifecycle Stage', + key: 'lifecycleStage', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.lifecycleStage', + value: 'contacttype', + }, + ], + }, + }, + { + label: 'Status', + key: 'status', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.status', + value: 'contactstatus', + }, + ], + }, + }, + { + label: 'Happiness Rating', + key: 'happinessRating', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.happinessRating', + value: 'happiness_rating', + }, + ], + }, + }, + { + label: 'Record Currency', + key: 'recordCurrency', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listRecordCurrencies', + }, + ], + }, + }, + { + label: 'Referred By', + key: 'referredBy', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContacts', + }, + ], + }, + }, + { + label: 'Email Opt-in', + key: 'emailOptin', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.emailOptin', + value: 'emailoptin', + }, + ], + }, + }, + { + label: 'SMS Opt-in', + key: 'smsOptin', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.smsOptin', + value: 'smsoptin', + }, + ], + }, + }, + { + label: 'Language', + key: 'language', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.language', + value: 'language', + }, + ], + }, + }, + { + label: 'Source Campaign', + key: 'sourceCampaign', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCampaignSources', + }, + ], + }, + }, + { + label: 'Portal User', + key: 'portalUser', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'True', value: '1' }, + { label: 'False', value: '-1' }, + ], + }, + { + label: 'Support Start Date', + key: 'supportStartDate', + type: 'string', + required: false, + description: 'format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Support End Date', + key: 'supportEndDate', + type: 'string', + required: false, + description: 'format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Other Country', + key: 'otherCountry', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.otherCountry', + value: 'othercountry', + }, + ], + }, + }, + { + label: 'Mailing Country', + key: 'mailingCountry', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.mailingCountry', + value: 'mailingcountry', + }, + ], + }, + }, + { + label: 'Mailing Street', + key: 'mailingStreet', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Other Street', + key: 'otherStreet', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Mailing PO Box', + key: 'mailingPoBox', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Other PO Box', + key: 'otherPoBox', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Mailing City', + key: 'mailingCity', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Other City', + key: 'otherCity', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Mailing State', + key: 'mailingState', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.mailingState', + value: 'mailingstate', + }, + ], + }, + }, + { + label: 'Other State', + key: 'otherState', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContactOptions', + }, + { + name: 'parameters.otherState', + value: 'otherstate', + }, + ], + }, + }, + { + label: 'Mailing Zip', + key: 'mailingZip', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Other Zip', + key: 'otherZip', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Description', + key: 'description', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Contact Image', + key: 'contactImage', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Linkedin URL', + key: 'linkedinUrl', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Linkedin Followers', + key: 'linkedinFollowers', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Facebook URL', + key: 'facebookUrl', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Facebook Followers', + key: 'facebookFollowers', + type: 'string', + required: false, + description: '', + variables: true, + }, +]; diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-contact/index.js b/packages/backend/src/apps/vtiger-crm/actions/create-contact/index.js new file mode 100644 index 00000000..35722c4d --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-contact/index.js @@ -0,0 +1,129 @@ +import defineAction from '../../../../helpers/define-action.js'; +import { fields } from './fields.js'; + +export default defineAction({ + name: 'Create contact', + key: 'createContact', + description: 'Create a new contact.', + arguments: fields, + + async run($) { + const { + salutation, + firstName, + lastName, + primaryEmail, + officePhone, + mobilePhone, + homePhone, + dateOfBirth, + fax, + organizationName, + title, + department, + reportsTo, + leadSource, + secondaryEmail, + assignedTo, + doNotCall, + notifyOwner, + twitterUsername, + slaName, + lifecycleStage, + status, + happinessRating, + recordCurrency, + referredBy, + emailOptin, + smsOptin, + language, + sourceCampaign, + portalUser, + supportStartDate, + supportEndDate, + otherCountry, + mailingCountry, + mailingStreet, + otherStreet, + mailingPoBox, + otherPoBox, + mailingCity, + otherCity, + mailingState, + otherState, + mailingZip, + otherZip, + description, + contactImage, + linkedinUrl, + linkedinFollowers, + facebookUrl, + facebookFollowers, + } = $.step.parameters; + + const elementData = { + salutationtype: salutation, + firstname: firstName, + lastname: lastName, + email: primaryEmail, + phone: officePhone, + mobile: mobilePhone, + homephone: homePhone, + birthday: dateOfBirth, + fax: fax, + account_id: organizationName, + title: title, + department: department, + contact_id: reportsTo, + leadsource: leadSource, + secondaryemail: secondaryEmail, + assigned_user_id: assignedTo || $.auth.data.userId, + donotcall: doNotCall, + notify_owner: notifyOwner, + emailoptout: emailOptin, + primary_twitter: twitterUsername, + slaid: slaName, + contacttype: lifecycleStage, + contactstatus: status, + happiness_rating: happinessRating, + record_currency_id: recordCurrency, + referred_by: referredBy, + emailoptin: emailOptin, + smsoptin: smsOptin, + language: language, + source_campaign: sourceCampaign, + portal: portalUser, + support_start_date: supportStartDate, + support_end_date: supportEndDate, + othercountry: otherCountry, + mailingcountry: mailingCountry, + mailingstreet: mailingStreet, + otherstreet: otherStreet, + mailingpobox: mailingPoBox, + otherpobox: otherPoBox, + mailingcity: mailingCity, + othercity: otherCity, + mailingstate: mailingState, + otherstate: otherState, + mailingzip: mailingZip, + otherzip: otherZip, + description: description, + imagename: contactImage, + primary_linkedin: linkedinUrl, + followers_linkedin: linkedinFollowers, + primary_facebook: facebookUrl, + followers_facebook: facebookFollowers, + }; + + const body = { + operation: 'create', + sessionName: $.auth.data.sessionName, + element: JSON.stringify(elementData), + elementType: 'Contacts', + }; + + const response = await $.http.post('/webservice.php', body); + + $.setActionItem({ raw: response.data }); + }, +}); diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-lead/fields.js b/packages/backend/src/apps/vtiger-crm/actions/create-lead/fields.js new file mode 100644 index 00000000..f8f28e20 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-lead/fields.js @@ -0,0 +1,395 @@ +export const fields = [ + { + label: 'Salutation', + key: 'salutation', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'Mr.', value: 'Mr.' }, + { label: 'Ms.', value: 'Ms.' }, + { label: 'Mrs.', value: 'Mrs.' }, + { label: 'Dr.', value: 'Dr.' }, + { label: 'Prof.', value: 'Prof.' }, + ], + }, + { + label: 'First Name', + key: 'firstName', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Last Name', + key: 'lastName', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Company', + key: 'company', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Primary Email', + key: 'primaryEmail', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Office Phone', + key: 'officePhone', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Designation', + key: 'designation', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.designation', + value: 'designation', + }, + ], + }, + }, + { + label: 'Mobile Phone', + key: 'mobilePhone', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Industry', + key: 'industry', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.industry', + value: 'industry', + }, + ], + }, + }, + { + label: 'Website', + key: 'website', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Annual Revenue', + key: 'annualRevenue', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Lead Source', + key: 'leadSource', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.leadSource', + value: 'leadsource', + }, + ], + }, + }, + { + label: 'Lead Status', + key: 'leadStatus', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.leadStatus', + value: 'leadstatus', + }, + ], + }, + }, + { + label: 'Assigned To', + key: 'assignedTo', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Fax', + key: 'fax', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Number of Employees', + key: 'numberOfEmployees', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Twitter Username', + key: 'twitterUsername', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Record Currency', + key: 'recordCurrency', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listRecordCurrencies', + }, + ], + }, + }, + { + label: 'Email Opt-in', + key: 'emailOptin', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.emailOptin', + value: 'emailoptin', + }, + ], + }, + }, + { + label: 'SMS Opt-in', + key: 'smsOptin', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.smsOptin', + value: 'smsoptin', + }, + ], + }, + }, + { + label: 'Language', + key: 'language', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.language', + value: 'language', + }, + ], + }, + }, + { + label: 'Source Campaign', + key: 'sourceCampaign', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCampaignSources', + }, + ], + }, + }, + { + label: 'Country', + key: 'country', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.country', + value: 'country', + }, + ], + }, + }, + { + label: 'Street', + key: 'street', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'PO Box', + key: 'poBox', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Postal Code', + key: 'postalCode', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'City', + key: 'city', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'State', + key: 'state', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listLeadOptions', + }, + { + name: 'parameters.state', + value: 'state', + }, + ], + }, + }, + { + label: 'Description', + key: 'description', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Lead Image', + key: 'leadImage', + type: 'string', + required: false, + description: '', + variables: true, + }, +]; diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-lead/index.js b/packages/backend/src/apps/vtiger-crm/actions/create-lead/index.js new file mode 100644 index 00000000..95d4a32f --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-lead/index.js @@ -0,0 +1,88 @@ +import defineAction from '../../../../helpers/define-action.js'; +import { fields } from './fields.js'; + +export default defineAction({ + name: 'Create lead', + key: 'createLead', + description: 'Create a new lead.', + arguments: fields, + + async run($) { + const { + salutation, + firstName, + lastName, + company, + primaryEmail, + officePhone, + designation, + mobilePhone, + industry, + website, + annualRevenue, + leadSource, + leadStatus, + assignedTo, + fax, + numberOfEmployees, + twitterUsername, + recordCurrency, + emailOptin, + smsOptin, + language, + sourceCampaign, + country, + street, + poBox, + postalCode, + city, + state, + description, + leadImage, + } = $.step.parameters; + + const elementData = { + salutationtype: salutation, + firstname: firstName, + lastname: lastName, + company: company, + email: primaryEmail, + phone: officePhone, + designation: designation, + mobile: mobilePhone, + industry: industry, + website: website, + annualrevenue: annualRevenue, + leadsource: leadSource, + leadstatus: leadStatus, + assigned_user_id: assignedTo || $.auth.data.userId, + fax: fax, + noofemployees: numberOfEmployees, + primary_twitter: twitterUsername, + record_currency_id: recordCurrency, + emailoptin: emailOptin, + smsoptin: smsOptin, + language: language, + source_campaign: sourceCampaign, + country: country, + lane: street, + pobox: poBox, + code: postalCode, + city: city, + state: state, + description: description, + imagename: leadImage, + }; + + const body = { + operation: 'create', + sessionName: $.auth.data.sessionName, + element: JSON.stringify(elementData), + elementType: 'Leads', + }; + + const response = await $.http.post('/webservice.php', body); + + $.setActionItem({ raw: response.data }); + }, +}); diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-opportunity/fields.js b/packages/backend/src/apps/vtiger-crm/actions/create-opportunity/fields.js new file mode 100644 index 00000000..557a62a6 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-opportunity/fields.js @@ -0,0 +1,244 @@ +export const fields = [ + { + label: 'Deal Name', + key: 'dealName', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Amount', + key: 'amount', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Organization Name', + key: 'organizationName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOrganizations', + }, + ], + }, + }, + { + label: 'Contact Name', + key: 'contactName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContacts', + }, + ], + }, + }, + { + label: 'Expected Close Date', + key: 'expectedCloseDate', + type: 'string', + required: true, + description: 'Format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Pipeline', + key: 'pipeline', + type: 'dropdown', + required: true, + value: 'Standart', + description: '', + variables: true, + options: [{ label: 'Standart', value: 'Standart' }], + }, + { + label: 'Sales Stage', + key: 'salesStage', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOpportunityOptions', + }, + { + name: 'parameters.salesStage', + value: 'sales_stage', + }, + ], + }, + }, + { + label: 'Assigned To', + key: 'assignedTo', + type: 'string', + required: false, + description: 'Default is the id of the account connected to Automatisch.', + variables: true, + }, + { + label: 'Lead Source', + key: 'leadSource', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOpportunityOptions', + }, + { + name: 'parameters.leadSource', + value: 'leadsource', + }, + ], + }, + }, + { + label: 'Next Step', + key: 'nextStep', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Type', + key: 'type', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOpportunityOptions', + }, + { + name: 'parameters.type', + value: 'opportunity_type', + }, + ], + }, + }, + { + label: 'Probability', + key: 'probability', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Campaign Source', + key: 'campaignSource', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listCampaignSources', + }, + ], + }, + }, + { + label: 'Weighted Revenue', + key: 'weightedRevenue', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Adjusted Amount', + key: 'adjustedAmount', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Lost Reason', + key: 'lostReason', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOpportunityOptions', + }, + { + name: 'parameters.lostReason', + value: 'lost_reason', + }, + ], + }, + }, + { + label: 'Record Currency', + key: 'recordCurrency', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listRecordCurrencies', + }, + ], + }, + }, + { + label: 'Description', + key: 'description', + type: 'string', + required: false, + description: '', + variables: true, + }, +]; diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-opportunity/index.js b/packages/backend/src/apps/vtiger-crm/actions/create-opportunity/index.js new file mode 100644 index 00000000..4a2e8571 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-opportunity/index.js @@ -0,0 +1,64 @@ +import defineAction from '../../../../helpers/define-action.js'; +import { fields } from './fields.js'; + +export default defineAction({ + name: 'Create opportunity', + key: 'createOpportunity', + description: 'Create a new opportunity.', + arguments: fields, + + async run($) { + const { + dealName, + amount, + organizationName, + contactName, + expectedCloseDate, + pipeline, + salesStage, + assignedTo, + leadSource, + nextStep, + type, + probability, + campaignSource, + weightedRevenue, + adjustedAmount, + lostReason, + recordCurrency, + description, + } = $.step.parameters; + + const elementData = { + potentialname: dealName, + amount, + related_to: organizationName, + contact_id: contactName, + closingdate: expectedCloseDate, + pipeline, + sales_stage: salesStage, + assigned_user_id: assignedTo || $.auth.data.userId, + leadsource: leadSource, + nextstep: nextStep, + opportunity_type: type, + probability: probability, + campaignid: campaignSource, + forecast_amount: weightedRevenue, + adjusted_amount: adjustedAmount, + lost_reason: lostReason, + record_currency_id: recordCurrency, + description, + }; + + const body = { + operation: 'create', + sessionName: $.auth.data.sessionName, + element: JSON.stringify(elementData), + elementType: 'Potentials', + }; + + const response = await $.http.post('/webservice.php', body); + + $.setActionItem({ raw: response.data }); + }, +}); diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-todo/fields.js b/packages/backend/src/apps/vtiger-crm/actions/create-todo/fields.js new file mode 100644 index 00000000..d386cc68 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-todo/fields.js @@ -0,0 +1,357 @@ +export const fields = [ + { + label: 'Name', + key: 'name', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Assigned To', + key: 'assignedTo', + type: 'string', + required: false, + description: 'Default is the id of the account connected to Automatisch.', + variables: true, + }, + { + label: 'Start Date & Time', + key: 'startDateAndTime', + type: 'string', + required: false, + description: 'Format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Due Date', + key: 'dueDate', + type: 'string', + required: false, + description: 'Format: yyyy-mm-dd', + variables: true, + }, + { + label: 'Stage', + key: 'stage', + type: 'dropdown', + required: true, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTodoOptions', + }, + { + name: 'parameters.stage', + value: 'taskstatus', + }, + ], + }, + }, + { + label: 'Contact Name', + key: 'contactName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listContacts', + }, + ], + }, + }, + { + label: 'Priority', + key: 'priority', + type: 'dropdown', + required: true, + description: '', + variables: true, + options: [ + { label: 'High', value: 'High' }, + { label: 'Medium', value: 'Medium' }, + { label: 'Low', value: 'Low' }, + ], + }, + { + label: 'Send Notification', + key: 'sendNotification', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'True', value: 'true' }, + { label: 'False', value: 'false' }, + ], + }, + { + label: 'Location', + key: 'location', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Record Currency', + key: 'recordCurrency', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listRecordCurrencies', + }, + ], + }, + }, + { + label: 'Milestone', + key: 'milestone', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listMilestones', + }, + ], + }, + }, + { + label: 'Previous Task', + key: 'previousTask', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTasks', + }, + ], + }, + }, + { + label: 'Parent Task', + key: 'parentTask', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTasks', + }, + ], + }, + }, + { + label: 'Task Type', + key: 'taskType', + type: 'dropdown', + required: true, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTodoOptions', + }, + { + name: 'parameters.taskType', + value: 'tasktype', + }, + ], + }, + }, + { + label: 'Skipped Reason', + key: 'skippedReason', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTodoOptions', + }, + { + name: 'parameters.skippedReason', + value: 'skipped_reason', + }, + ], + }, + }, + { + label: 'Estimate', + key: 'estimate', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Related Task', + key: 'relatedTask', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTasks', + }, + ], + }, + }, + { + label: 'Project Name', + key: 'projectName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listProjects', + }, + ], + }, + }, + { + label: 'Organization Name', + key: 'organizationName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listOrganizations', + }, + ], + }, + }, + { + label: 'Send Email Reminder Before', + key: 'sendEmailReminderBefore', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Description', + key: 'description', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Is Billable', + key: 'isBillable', + type: 'dropdown', + required: false, + description: '', + variables: true, + options: [ + { label: 'True', value: '1' }, + { label: 'False', value: '-1' }, + ], + }, + { + label: 'Service', + key: 'service', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listServices', + }, + ], + }, + }, + { + label: 'Rate', + key: 'rate', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'SLA Name', + key: 'slaName', + type: 'dropdown', + required: false, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listSlaNames', + }, + ], + }, + }, +]; diff --git a/packages/backend/src/apps/vtiger-crm/actions/create-todo/index.js b/packages/backend/src/apps/vtiger-crm/actions/create-todo/index.js new file mode 100644 index 00000000..295d0c7f --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/create-todo/index.js @@ -0,0 +1,78 @@ +import defineAction from '../../../../helpers/define-action.js'; +import { fields } from './fields.js'; + +export default defineAction({ + name: 'Create todo', + key: 'createTodo', + description: 'Create a new todo.', + arguments: fields, + + async run($) { + const { + name, + assignedTo, + startDateAndTime, + dueDate, + stage, + contactName, + priority, + sendNotification, + location, + recordCurrency, + milestone, + previousTask, + parentTask, + taskType, + skippedReason, + estimate, + relatedTask, + projectName, + organizationName, + sendEmailReminderBefore, + description, + isBillable, + service, + rate, + slaName, + } = $.step.parameters; + + const elementData = { + subject: name, + assigned_user_id: assignedTo || $.auth.data.userId, + date_start: startDateAndTime, + due_date: dueDate, + taskstatus: stage, + contact_id: contactName, + taskpriority: priority, + sendnotification: sendNotification, + location: location, + record_currency_id: recordCurrency, + milestone: milestone, + dependent_on: previousTask, + parent_task: parentTask, + tasktype: taskType, + skipped_reason: skippedReason, + estimate: estimate, + related_task: relatedTask, + related_project: projectName, + account_id: organizationName, + reminder_time: sendEmailReminderBefore, + description: description, + is_billable: isBillable, + billing_service: service, + rate: rate, + slaid: slaName, + }; + + const body = { + operation: 'create', + sessionName: $.auth.data.sessionName, + element: JSON.stringify(elementData), + elementType: 'Calendar', + }; + + const response = await $.http.post('/webservice.php', body); + + $.setActionItem({ raw: response.data }); + }, +}); diff --git a/packages/backend/src/apps/vtiger-crm/actions/index.js b/packages/backend/src/apps/vtiger-crm/actions/index.js new file mode 100644 index 00000000..a4cd130d --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/actions/index.js @@ -0,0 +1,13 @@ +import createCase from './create-case/index.js'; +import createContact from './create-contact/index.js'; +import createLead from './create-lead/index.js'; +import createOpportunity from './create-opportunity/index.js'; +import createTodo from './create-todo/index.js'; + +export default [ + createCase, + createContact, + createLead, + createOpportunity, + createTodo, +]; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/index.js new file mode 100644 index 00000000..c3ee6aca --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/index.js @@ -0,0 +1,39 @@ +import listAssets from './list-assets/index.js'; +import listCampaignSources from './list-campaign-sources/index.js'; +import listCaseOptions from './list-case-options/index.js'; +import listContactOptions from './list-contact-options/index.js'; +import listContacts from './list-contacts/index.js'; +import listGroups from './list-groups/index.js'; +import listLeadOptions from './list-lead-options/index.js'; +import listMilestones from './list-milestones/index.js'; +import listOpportunityOptions from './list-opportunity-options/index.js'; +import listOrganizations from './list-organizations/index.js'; +import listProducts from './list-products/index.js'; +import listProjects from './list-projects/index.js'; +import listRecordCurrencies from './list-record-currencies/index.js'; +import listServiceContracts from './list-service-contracts/index.js'; +import listServices from './list-services/index.js'; +import listSlaNames from './list-sla-names/index.js'; +import listTasks from './list-tasks/index.js'; +import listTodoOptions from './list-todo-options/index.js'; + +export default [ + listAssets, + listCampaignSources, + listCaseOptions, + listContactOptions, + listContacts, + listGroups, + listLeadOptions, + listMilestones, + listOpportunityOptions, + listOrganizations, + listProducts, + listProjects, + listRecordCurrencies, + listServiceContracts, + listServices, + listSlaNames, + listTasks, + listTodoOptions, +]; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-assets/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-assets/index.js new file mode 100644 index 00000000..3606a4f9 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-assets/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List assets', + key: 'listAssets', + + async run($) { + const assets = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Assets ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const asset of data.result) { + assets.data.push({ + value: asset.id, + name: `${asset.assetname} (${asset.assetstatus})`, + }); + } + } + + return assets; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-campaign-sources/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-campaign-sources/index.js new file mode 100644 index 00000000..e2551278 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-campaign-sources/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List campaign sources', + key: 'listCampaignSources', + + async run($) { + const campaignSources = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Campaigns ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result?.length) { + for (const campaignSource of data.result) { + campaignSources.data.push({ + value: campaignSource.id, + name: campaignSource.campaignname, + }); + } + } + + return campaignSources; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-case-options/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-case-options/index.js new file mode 100644 index 00000000..9cc0163b --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-case-options/index.js @@ -0,0 +1,58 @@ +export default { + name: 'List case options', + key: 'listCaseOptions', + + async run($) { + const caseOptions = { + data: [], + }; + const { + status, + priority, + contactName, + productName, + channel, + category, + subCategory, + resolutionType, + serviceType, + serviceLocation, + } = $.step.parameters; + + const picklistFields = [ + status, + priority, + contactName, + productName, + channel, + category, + subCategory, + resolutionType, + serviceType, + serviceLocation, + ]; + + const params = { + operation: 'describe', + sessionName: $.auth.data.sessionName, + elementType: 'Cases', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result.fields?.length) { + for (const field of data.result.fields) { + if (picklistFields.includes(field.name)) { + field.type.picklistValues.map((item) => + caseOptions.data.push({ + value: item.value, + name: item.label, + }) + ); + } + } + } + + return caseOptions; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-contact-options/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-contact-options/index.js new file mode 100644 index 00000000..e27257d4 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-contact-options/index.js @@ -0,0 +1,62 @@ +export default { + name: 'List contact options', + key: 'listContactOptions', + + async run($) { + const leadOptions = { + data: [], + }; + const { + leadSource, + lifecycleStage, + status, + title, + happinessRating, + emailOptin, + smsOptin, + language, + otherCountry, + mailingCountry, + mailingState, + otherState, + } = $.step.parameters; + + const picklistFields = [ + leadSource, + lifecycleStage, + status, + title, + happinessRating, + emailOptin, + smsOptin, + language, + otherCountry, + mailingCountry, + mailingState, + otherState, + ]; + + const params = { + operation: 'describe', + sessionName: $.auth.data.sessionName, + elementType: 'Contacts', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result.fields?.length) { + for (const field of data.result.fields) { + if (picklistFields.includes(field.name)) { + field.type.picklistValues.map((item) => + leadOptions.data.push({ + value: item.value, + name: item.label, + }) + ); + } + } + } + + return leadOptions; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-contacts/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-contacts/index.js new file mode 100644 index 00000000..c2d8c6ff --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-contacts/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List contacts', + key: 'listContacts', + + async run($) { + const contacts = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Contacts ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result?.length) { + for (const contact of data.result) { + contacts.data.push({ + value: contact.id, + name: `${contact.firstname} ${contact.lastname}`, + }); + } + } + + return contacts; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-groups/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-groups/index.js new file mode 100644 index 00000000..51112b04 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-groups/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List groups', + key: 'listGroups', + + async run($) { + const groups = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Groups;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const group of data.result) { + groups.data.push({ + value: group.id, + name: group.groupname, + }); + } + } + + return groups; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-lead-options/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-lead-options/index.js new file mode 100644 index 00000000..bd7ab650 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-lead-options/index.js @@ -0,0 +1,56 @@ +export default { + name: 'List lead options', + key: 'listLeadOptions', + + async run($) { + const leadOptions = { + data: [], + }; + const { + designation, + industry, + leadSource, + leadStatus, + emailOptin, + smsOptin, + language, + country, + state, + } = $.step.parameters; + + const picklistFields = [ + designation, + industry, + leadSource, + leadStatus, + emailOptin, + smsOptin, + language, + country, + state, + ]; + + const params = { + operation: 'describe', + sessionName: $.auth.data.sessionName, + elementType: 'Leads', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result.fields?.length) { + for (const field of data.result.fields) { + if (picklistFields.includes(field.name)) { + field.type.picklistValues.map((item) => + leadOptions.data.push({ + value: item.value, + name: item.label, + }) + ); + } + } + } + + return leadOptions; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-milestones/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-milestones/index.js new file mode 100644 index 00000000..9bc7a50c --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-milestones/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List milestones', + key: 'listMilestones', + + async run($) { + const milestones = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM ProjectMilestone ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const milestone of data.result) { + milestones.data.push({ + value: milestone.id, + name: milestone.projectmilestonename, + }); + } + } + + return milestones; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-opportunity-options/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-opportunity-options/index.js new file mode 100644 index 00000000..b86cd731 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-opportunity-options/index.js @@ -0,0 +1,38 @@ +export default { + name: 'List opportunity options', + key: 'listOpportunityOptions', + + async run($) { + const opportunityOptions = { + data: [], + }; + const leadSource = $.step.parameters.leadSource; + const lostReason = $.step.parameters.lostReason; + const type = $.step.parameters.type; + const salesStage = $.step.parameters.salesStage; + const picklistFields = [leadSource, lostReason, type, salesStage]; + + const params = { + operation: 'describe', + sessionName: $.auth.data.sessionName, + elementType: 'Potentials', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result.fields?.length) { + for (const field of data.result.fields) { + if (picklistFields.includes(field.name)) { + field.type.picklistValues.map((item) => + opportunityOptions.data.push({ + value: item.value, + name: item.label, + }) + ); + } + } + } + + return opportunityOptions; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-organizations/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-organizations/index.js new file mode 100644 index 00000000..77b60302 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-organizations/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List organizations', + key: 'listOrganizations', + + async run($) { + const organizations = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Accounts ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result?.length) { + for (const organization of data.result) { + organizations.data.push({ + value: organization.id, + name: organization.accountname, + }); + } + } + + return organizations; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-products/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-products/index.js new file mode 100644 index 00000000..f4be10c4 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-products/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List products', + key: 'listProducts', + + async run($) { + const products = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Products ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const product of data.result) { + products.data.push({ + value: product.id, + name: product.productname, + }); + } + } + + return products; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-projects/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-projects/index.js new file mode 100644 index 00000000..ec12956b --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-projects/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List projects', + key: 'listProjects', + + async run($) { + const projects = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Project ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const project of data.result) { + projects.data.push({ + value: project.id, + name: project.projectname, + }); + } + } + + return projects; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-record-currencies/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-record-currencies/index.js new file mode 100644 index 00000000..b416a650 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-record-currencies/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List record currencies', + key: 'listRecordCurrencies', + + async run($) { + const recordCurrencies = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Currency;', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result?.length) { + for (const recordCurrency of data.result) { + recordCurrencies.data.push({ + value: recordCurrency.id, + name: recordCurrency.currency_code, + }); + } + } + + return recordCurrencies; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-service-contracts/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-service-contracts/index.js new file mode 100644 index 00000000..d67e5d02 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-service-contracts/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List service contracts', + key: 'listServiceContracts', + + async run($) { + const serviceContracts = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM ServiceContracts ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const serviceContract of data.result) { + serviceContracts.data.push({ + value: serviceContract.id, + name: serviceContract.subject, + }); + } + } + + return serviceContracts; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-services/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-services/index.js new file mode 100644 index 00000000..c08c4ae1 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-services/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List services', + key: 'listServices', + + async run($) { + const services = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Services ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const service of data.result) { + services.data.push({ + value: service.id, + name: service.servicename, + }); + } + } + + return services; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-sla-names/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-sla-names/index.js new file mode 100644 index 00000000..5026c828 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-sla-names/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List sla names', + key: 'listSlaNames', + + async run($) { + const slaNames = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM SLA ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get(`/webservice.php`, { params }); + + if (data.result?.length) { + for (const slaName of data.result) { + slaNames.data.push({ + value: slaName.id, + name: slaName.policy_name, + }); + } + } + + return slaNames; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-tasks/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-tasks/index.js new file mode 100644 index 00000000..87c174f9 --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-tasks/index.js @@ -0,0 +1,29 @@ +export default { + name: 'List tasks', + key: 'listTasks', + + async run($) { + const tasks = { + data: [], + }; + + const params = { + operation: 'query', + sessionName: $.auth.data.sessionName, + query: 'SELECT * FROM Calendar ORDER BY createdtime DESC;', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result?.length) { + for (const task of data.result) { + tasks.data.push({ + value: task.id, + name: task.subject, + }); + } + } + + return tasks; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/dynamic-data/list-todo-options/index.js b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-todo-options/index.js new file mode 100644 index 00000000..ca0d1f4c --- /dev/null +++ b/packages/backend/src/apps/vtiger-crm/dynamic-data/list-todo-options/index.js @@ -0,0 +1,37 @@ +export default { + name: 'List todo options', + key: 'listTodoOptions', + + async run($) { + const todoOptions = { + data: [], + }; + const stage = $.step.parameters.stage; + const taskType = $.step.parameters.taskType; + const skippedReason = $.step.parameters.skippedReason; + const picklistFields = [stage, taskType, skippedReason]; + + const params = { + operation: 'describe', + sessionName: $.auth.data.sessionName, + elementType: 'Calendar', + }; + + const { data } = await $.http.get('/webservice.php', { params }); + + if (data.result.fields?.length) { + for (const field of data.result.fields) { + if (picklistFields.includes(field.name)) { + field.type.picklistValues.map((item) => + todoOptions.data.push({ + value: item.value, + name: item.label, + }) + ); + } + } + } + + return todoOptions; + }, +}; diff --git a/packages/backend/src/apps/vtiger-crm/index.js b/packages/backend/src/apps/vtiger-crm/index.js index f1f6fceb..9a706039 100644 --- a/packages/backend/src/apps/vtiger-crm/index.js +++ b/packages/backend/src/apps/vtiger-crm/index.js @@ -3,6 +3,8 @@ import addAuthHeader from './common/add-auth-header.js'; import setBaseUrl from './common/set-base-url.js'; import auth from './auth/index.js'; import triggers from './triggers/index.js'; +import actions from './actions/index.js'; +import dynamicData from './dynamic-data/index.js'; export default defineApp({ name: 'Vtiger CRM', @@ -16,4 +18,6 @@ export default defineApp({ beforeRequest: [setBaseUrl, addAuthHeader], auth, triggers, + actions, + dynamicData, }); diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js index 1bbb537e..490bf6ee 100644 --- a/packages/docs/pages/.vitepress/config.js +++ b/packages/docs/pages/.vitepress/config.js @@ -454,6 +454,7 @@ export default defineConfig({ collapsed: true, items: [ { text: 'Triggers', link: '/apps/vtiger-crm/triggers' }, + { text: 'Actions', link: '/apps/vtiger-crm/actions' }, { text: 'Connection', link: '/apps/vtiger-crm/connection' }, ], }, diff --git a/packages/docs/pages/apps/vtiger-crm/actions.md b/packages/docs/pages/apps/vtiger-crm/actions.md new file mode 100644 index 00000000..b4985053 --- /dev/null +++ b/packages/docs/pages/apps/vtiger-crm/actions.md @@ -0,0 +1,20 @@ +--- +favicon: /favicons/vtiger-crm.svg +items: + - name: Create case + desc: Create a new case. + - name: Create contact + desc: Create a new contact. + - name: Create opportunity + desc: Create a new opportunity. + - name: Create todo + desc: Create a new todo. + - name: Create lead + desc: Create a new lead. +--- + + + +