2022-08-01 13:47:55 -07:00
import { INodeProperties } from 'n8n-workflow' ;
2022-07-10 01:37:41 -07:00
export const searchOperations : INodeProperties [ ] = [
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
noDataExpression : true ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
options : [
{
name : 'Query' ,
value : 'query' ,
description : 'Search for records by entering search queries of your choice' ,
2022-07-13 01:38:12 -07:00
action : 'Query a search' ,
2022-07-10 01:37:41 -07:00
} ,
{
name : 'Lookup' ,
value : 'lookup' ,
description : 'Search for the name or email address of records' ,
2022-07-13 01:38:12 -07:00
action : 'Lookup a search' ,
2022-07-10 01:37:41 -07:00
} ,
] ,
default : 'query' ,
} ,
] ;
export const searchFields : INodeProperties [ ] = [
// ----------------------------------------
// Search: query
// ----------------------------------------
{
displayName : 'Search Term' ,
name : 'query' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'query' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
description : 'Enter a term that will be used for searching entities' ,
} ,
{
displayName : 'Search on Entities' ,
name : 'entities' ,
type : 'multiOptions' ,
options : [
{
name : 'Contact' ,
value : 'contact' ,
} ,
{
name : 'Deal' ,
value : 'deal' ,
} ,
{
name : 'Sales Account' ,
value : 'sales_account' ,
} ,
{
name : 'User' ,
value : 'user' ,
} ,
] ,
required : true ,
default : [ ] ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'query' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
description : 'Enter a term that will be used for searching entities' ,
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'query' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
description : 'Whether to return all results or only up to a given limit' ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
2022-07-10 02:20:57 -07:00
typeOptions : {
minValue : 1 ,
} ,
2022-07-10 01:37:41 -07:00
default : 25 ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'query' ] ,
returnAll : [ false ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
description : 'Max number of results to return' ,
} ,
// ----------------------------------------
// Search: lookup
// ----------------------------------------
{
displayName : 'Search Field' ,
name : 'searchField' ,
type : 'options' ,
options : [
{
name : 'Email' ,
value : 'email' ,
} ,
{
name : 'Name' ,
value : 'name' ,
} ,
{
name : 'Custom Field' ,
value : 'customField' ,
2022-08-01 13:47:55 -07:00
description :
'Only allowed custom fields of type "Text field", "Number", "Dropdown" or "Radio button"' ,
2022-07-10 01:37:41 -07:00
} ,
] ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'lookup' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
description : 'Field against which the entities have to be searched' ,
} ,
{
displayName : 'Custom Field Name' ,
name : 'customFieldName' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'lookup' ] ,
searchField : [ 'customField' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
} ,
{
displayName : 'Custom Field Value' ,
name : 'customFieldValue' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'lookup' ] ,
searchField : [ 'customField' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
} ,
{
displayName : 'Field Value' ,
name : 'fieldValue' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'lookup' ] ,
searchField : [ 'email' , 'name' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'search' ] ,
operation : [ 'lookup' ] ,
2022-07-10 01:37:41 -07:00
} ,
} ,
options : [
{
displayName : 'Entities' ,
name : 'entities' ,
type : 'multiOptions' ,
default : [ ] ,
options : [
{
name : 'Contact' ,
value : 'contact' ,
} ,
{
name : 'Deal' ,
value : 'deal' ,
} ,
{
name : 'Sales Account' ,
value : 'sales_account' ,
} ,
] ,
2022-08-01 13:47:55 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-description-unneeded-backticks
description : ` Use 'entities' to query against related entities. You can include multiple entities at once, provided the field is available in both entities or else you'd receive an error response. ` ,
2022-07-10 01:37:41 -07:00
} ,
] ,
} ,
] ;