Forms
Marketo forms具有一组复杂的端点,允许从远程系统完全控制表单管理。 表单的结构可能很复杂,因为作为表单的一部分,必须管理许多不同类型的对象:Forms、字段、字段集、可见性规则和后续页面规则。
查询
贵辞谤尘蝉支持资源检索的标准方法,即、和。 每个表单响应都包含其所有属性,但字段列表除外。
按滨顿
将表单id
作为路径参数并返回表单记录。
GET /rest/asset/v1/form/{id}.json
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "948f#154e3bad8e3",
"result": [
{
"id": 736,
"name": "newForm",
"description": "test",
"createdAt": "2016-05-24T17:05:54Z+0000",
"updatedAt": "2016-05-24T17:05:54Z+0000",
"url": "https://app-devlocal1.marketo.com/#FO736B2",
"status": "draft",
"theme": "simple",
"language": "French",
"locale": "fr_FR",
"progressiveProfiling": false,
"labelPosition": "left",
"fontFamily": "Helvetica",
"fontSize": "13px",
"folder": {
"type": "Folder",
"value": 293,
"folderName": "yyLNLHzgOM"
},
"knownVisitor": {
"type": "form",
"template": null
},
"thankYouList": [
{
"followupType": "none",
"followupValue": null,
"default": true
}
],
"buttonLocation": 120,
"buttonLabel": "Envoyer",
"waitingLabel": "Veuillez patienter"
}
]
}
按名称
将表单name
作为路径参数并返回表单记录。
GET /rest/asset/v1/form/byName.json?name=newForm
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "948f#154e3bad8e3",
"result": [
{
"id": 736,
"name": "newForm",
"description": "test",
"createdAt": "2016-05-24T17:05:54Z+0000",
"updatedAt": "2016-05-24T17:05:54Z+0000",
"url": "https://app-devlocal1.marketo.com/#FO736B2",
"status": "draft",
"theme": "simple",
"language": "French",
"locale": "fr_FR",
"progressiveProfiling": false,
"labelPosition": "left",
"fontFamily": "Helvetica",
"fontSize": "13px",
"folder": {
"type": "Folder",
"value": 293,
"folderName": "yyLNLHzgOM"
},
"knownVisitor": {
"type": "form",
"template": null
},
"thankYouList": [
{
"followupType": "none",
"followupValue": null,
"default": true
}
],
"buttonLocation": 120,
"buttonLabel": "Envoyer",
"waitingLabel": "Veuillez patienter"
}
]
}
浏览
表单的工作方式与其他Asset API浏览端点类似,允许对status
、maxReturn
和offset
进行可选筛选。 状态可以是:已批准、带草稿的已批准或草稿。
GET /rest/asset/v1/forms.json
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "645d#154e3d499ac",
"result": [
{
"id": 227,
"name": "aKAUVDfbsX",
"description": "",
"createdAt": "2016-05-18T20:36:20Z+0000",
"updatedAt": "2016-05-18T20:36:20Z+0000",
"url": "https://app-devlocal1.marketo.com/#FO227B2",
"status": "draft",
"theme": "simple",
"language": "English",
"locale": "en_US",
"progressiveProfiling": false,
"labelPosition": "left",
"fontFamily": "Helvetica",
"fontSize": "13px",
"folder": {
"type": "Folder",
"value": 293,
"folderName": "yyLNLHzgOM"
},
"knownVisitor": {
"type": "form",
"template": null
},
"thankYouList": [
{
"followupType": "none",
"followupValue": null,
"default": true
}
],
"buttonLocation": 120,
"buttonLabel": "Submit",
"waitingLabel": "Please Wait"
},
{
"id": 695,
"name": "AoMXgfFbma",
"description": "",
"createdAt": "2016-05-19T18:50:40Z+0000",
"updatedAt": "2016-05-19T18:50:40Z+0000",
"url": "https://app-devlocal1.marketo.com/#FO695B2",
"status": "draft",
"theme": "simple",
"language": "English",
"locale": "en_US",
"progressiveProfiling": true,
"labelPosition": "left",
"fontFamily": "Helvetica",
"fontSize": "13px",
"folder": {
"type": "Folder",
"value": 565,
"folderName": "WfUvYmlcyT"
},
"knownVisitor": {
"type": "form",
"template": null
},
"thankYouList": [
{
"followupType": "none",
"followupValue": null,
"default": true
}
],
"buttonLocation": 120,
"buttonLabel": "Submit",
"waitingLabel": "Please Wait"
}
]
}
字段列表
检索表单的字段列表是基于每个表单完成的。
GET /rest/asset/v1/form/{id}/fields.json
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "2165#154eee00d01",
"result": [
{
"id": "FirstName",
"label": "First Name:",
"dataType": "text",
"validationMessage": "This field is required.",
"rowNumber": 0,
"columnNumber": 0,
"maxLength": 255,
"required": false,
"formPrefill": true,
"visibilityRules": {
"ruleType": "alwaysShow"
}
},
{
"id": "LastName",
"label": "Last Name:",
"dataType": "text",
"validationMessage": "This field is required.",
"rowNumber": 1,
"columnNumber": 0,
"maxLength": 255,
"required": false,
"formPrefill": true,
"visibilityRules": {
"ruleType": "alwaysShow"
}
},
{
"id": "Email",
"label": "Email Address:",
"dataType": "email",
"validationMessage": "Must be valid email. <span class='mktoErrorDetail'>example@yourdomain.com</span>",
"rowNumber": 2,
"columnNumber": 0,
"required": false,
"formPrefill": true,
"visibilityRules": {
"ruleType": "alwaysShow"
}
},
{
"id": "Profiling",
"dataType": "profiling",
"rowNumber": 3,
"columnNumber": 0
}
]
}
在编辑字段或表单中的字段行为时,应始终在尝试编辑之前检索字段列表。 这可确保在更新或删除时提供正确的字段ID。
字段类型
依赖关系
端点将表单id
作为路径参数并返回依赖该表单的资源列表。 Forms可用于以下资源类型:登陆页面、智能列表、智能营销活动、报表、电子邮件项目。
GET /rest/asset/v1/form/{id}/usedBy.json
{
"success": true,
"errors": [],
"requestId": "fdf4#17285b25038",
"warnings": [],
"result": [
{
"id": 1038,
"name": "LP Redirect Rules Program.LP Test 01",
"type": "Landing Page",
"status": "approved",
"updatedAt": "2020-02-23T01:31:21Z+0000"
}
]
}
创建和更新
在时,只有两个必填字段:表单的父文件夹、表单的名称。 所有其他参数均为可选参数,且使用默认值。 创建表单时带有三个默认字段:名字、姓氏、电子邮件。
POST /rest/asset/v1/forms.json
Content-Type: application/x-www-form-urlencoded
name=newForm&description=test&folder={"type": "Folder","id": 293}&language=French
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "948f#154e3bad8e3",
"result": [
{
"id": 736,
"name": "newForm",
"description": "test",
"createdAt": "2016-05-24T17:05:54Z+0000",
"updatedAt": "2016-05-24T17:05:54Z+0000",
"url": "https://app-devlocal1.marketo.com/#FO736B2",
"status": "draft",
"theme": "simple",
"language": "French",
"locale": "fr_FR",
"progressiveProfiling": false,
"labelPosition": "left",
"fontFamily": "Helvetica",
"fontSize": "13px",
"folder": {
"type": "Folder",
"value": 293,
"folderName": "yyLNLHzgOM"
},
"knownVisitor": {
"type": "form",
"template": null
},
"thankYouList": [
{
"followupType": "none",
"followupValue": null,
"default": true
}
],
"buttonLocation": 120,
"buttonLabel": "Envoyer",
"waitingLabel": "Veuillez patienter"
}
]
}
贵辞谤尘蝉通过其滨顿使用类似的调用。 在创建或更新期间,任何基本样式参数均可访问和编辑,从而允许您修改向最终用户显示表单的方式。
POST /rest/asset/v1/form/736.json
Content-Type: application/x-www-form-urlencoded
name=updated name&description=This is a test for updateapi&language=English&progressiveProfiling=true&locale=en_US
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "6307#154e3cf6efe",
"result": [
{
"id": 736,
"name": "updated name",
"description": "This is a test for update api",
"createdAt": "2016-05-24T17:05:54Z+0000",
"updatedAt": "2016-05-24T17:28:23Z+0000",
"status": "draft",
"theme": "simple",
"language": "English",
"locale": "en_US",
"progressiveProfiling": true,
"labelPosition": "left",
"fontFamily": "Helvetica",
"fontSize": "13px",
"folder": {
"type": "Folder",
"value": 293,
"folderName": "yyLNLHzgOM"
},
"knownVisitor": {
"type": "form",
"template": null
},
"thankYouList": [
{
"followupType": "none",
"followupValue": null,
"default": true
}
],
"buttonLocation": 120,
"buttonLabel": "Submit",
"waitingLabel": "Please Wait"
}
]
}
已知访客和感谢页面行为无法通过创建或更新表单调用进行修改,必须通过其各自的端点进行访问。
字段元数据
要正确添加或编辑属于表单的字段,必须检索目标实例的有效字段列表。 字段交互始终根据为结果中的每个项目显示的字段id属性来完成。
对于“潜在客户”字段,可使用端点完成此操作,并且包括字段的数据类型和默认元数据(添加到表单时)。
GET /rest/asset/v1/form/fields.json
{
"success": true,
"errors": [],
"requestId": "176ca#167a9808f4c",
"warnings": [],
"result": [
{
"id": "AnnualRevenue",
"isRequired": false,
"dataType": "currency"
},
{
"id": "City",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "Company",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "Country",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "Description",
"isRequired": false,
"dataType": "textarea",
"maxLength": 32000,
"visibleRows": 2
},
{
"id": "Email",
"isRequired": false,
"dataType": "email"
},
{
"id": "Fax",
"isRequired": false,
"dataType": "phone"
},
{
"id": "FirstName",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "Industry",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "LastName",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "LeadSource",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "MobilePhone",
"isRequired": false,
"dataType": "phone"
},
{
"id": "NumberOfEmployees",
"isRequired": false,
"dataType": "int"
},
{
"id": "Phone",
"isRequired": false,
"dataType": "phone"
},
{
"id": "PostalCode",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "Rating",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "Salutation",
"isRequired": false,
"dataType": "picklist",
"picklistValues": "Mr.,Ms.,Mrs.,Dr.,Prof."
},
{
"id": "State",
"isRequired": false,
"dataType": "picklist",
"picklistValues": "AK::AK,AL::AL,AR::AR,AZ::AZ,CA::CA,CO::CO,CT::CT,DE::DE,FL::FL,GA::GA,HI::HI,IA::IA,ID::ID,IL::IL,IN::IN,KS::KS,KY::KY,LA::LA,MA::MA,MD::MD,ME::ME,MI::MI,MN::MN,MO::MO,MS::MS,MT::MT,NC::NC,ND::ND,NE::NE,NH::NH,NJ::NJ,NM::NM,NV::NV,NY::NY,OH::OH,OK::OK,OR::OR,PA::PA,RI::RI,SC::SC,SD::SD,TN::TN,TX::TX,UT::UT,VA::VA,VT::VT,WA::WA,WI::WI,WV::WV,WY::WY"
},
{
"id": "Street",
"isRequired": false,
"dataType": "textarea",
"maxLength": 2000,
"visibleRows": 2
},
{
"id": "Title",
"isRequired": false,
"dataType": "picklist"
}
]
}
对于计划成员自定义字段,请调用? 端点,用于检索程序成员自定义字段数据类型和默认元数据。 要在表单中使用这些字段,表单必须位于程序下(而不是在Design Studio中)。 包含使用这些字段的表单的登陆页面还必须位于程序下(不能位于Design Studio中,也不能克隆到Design Studio中)。
GET /rest/asset/v1/form/programMemberFields.json
{
"success": true,
"errors": [],
"requestId": "109c6#16fa0b9c51a",
"warnings": [],
"result": [
{
"id": "pMCFCustomField01",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "pMCFCustomField02",
"isRequired": false,
"dataType": "string",
"maxLength": 255
},
{
"id": "myPMCF",
"isRequired": false,
"dataType": "string",
"maxLength": 255
}
]
}
编辑字段
每个表单都包含一个可编辑的字段列表,在加载时将会显示给最终用户。 通过每个字段各自的端点,一次在字段列表中添加、更新或删除一个字段。
只需要父表单的ID和字段的fieldId。 所有其他字段将为空或者其默认值基于其数据类型和字段元数据。 数据以x-www-form-urlencodedPOST传递,而不是以JSON格式传递。
POST /rest/asset/v1/form/{id}/fields.json
Content-Type: application/x-www-form-urlencoded
fieldId=NumberOfEmployees&maxLength=125&defaultValue=this is default&required=true&fieldWidth=100&validationMessage=hey, you there?&label=employee count&hintText=Hint me&minValue=10
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "1826e#154f41b214c",
"result": [
{
"id": "NumberOfEmployees",
"label": "employee count",
"fieldWidth": 100,
"dataType": "number",
"defaultValue": "this is default",
"validationMessage": "hey, you there?",
"rowNumber": 5,
"columnNumber": 0,
"required": true,
"formPrefill": true,
"fieldMetaData": {
"minValue": 10,
"maxValue": null
},
"visibilityRules": {
"ruleType": "alwaysShow"
},
"hintText": "Hint me"
}
]
}
更新可能会编辑与添加字段相同的所有字段,并且同样需要表单滨顿和字段滨顿,但以下情况除外:执行更新时,蹿颈别濒诲滨诲是路径参数,而不是查询参数。
POST /rest/asset/v1/form/{id}/field/LastName.json
Content-Type: application/x-www-form-urlencoded
label=enter the last name here
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "5634#15508303abb",
"result": [
{
"id": "LastName",
"label": "enter the last name here",
"dataType": "text",
"validationMessage": "This field is required.",
"rowNumber": 0,
"columnNumber": 0,
"maxLength": 255,
"required": false,
"formPrefill": true,
"visibilityRules": {
"ruleType": "alwaysShow"
}
}
]
}
在上述示例中,我们将更新简单字符串形式的LastName字段。 有些表单字段比较复杂。 例如,“称谓”字段是“选择”字段类型,其中包含项目列表和默认值。 如果添加或更新选择类型字段,除非将其中一个选项设置为isDefault
值迟谤耻别,否则第一个选项没有值,且标记为“厂别濒别肠迟…”
要更新列表项,“惫补濒耻别蝉”参数的格式如下:
POST /rest/asset/v1/form/{id}/field/Salutation.json
Content-Type: application/x-www-form-urlencoded
values=[{"label":"Select...","value":"","isDefault":true,"selected":true}, {"label":"MR","value":"MR"}, {"label":"MS","value":"MS"}, {"label":"MRS","value":"MRS"}, {"label":"DR","value":"DR"}, {"label":"PROF","value":"PROF"}]
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "71fd#1588d9d1b0c",
"result": [
{
"id": "Salutation",
"label": "Salutation:",
"dataType": "select",
"validationMessage": "This field is required.",
"rowNumber": 3,
"columnNumber": 0,
"required": false,
"formPrefill": true,
"fieldMetaData": {
"multiSelect": false,
"values": [
{
"label": "Select...",
"value": "",
"isDefault": true,
"selected": true
},
{
"label": "MR",
"value": "MR"
},
{
"label": "MS",
"value": "MS"
},
{
"label": "MRS",
"value": "MRS"
},
{
"label": "DR",
"value": "DR"
},
{
"label": "PROF",
"value": "PROF"
}
],
"visibleLines": 1
},
"visibilityRules": {
"ruleType": "alwaysShow"
}
}
]
}
要确定如何设置复杂表单字段的格式,请查看将字段添加到表单中的响应。
重新排列字段
表单中的字段必须通过端点以单个单元的方式重新排列所有。 终结点需要一个名为positions
的参数,该参数是一个包含叁个成员的闯厂翱狈对象数组:
- 列号
- rowNumber
- 蹿颈别濒诲狈补尘别(指字段的颈诲)
表单中的字段以类似表格的界面排列,最多三列和十行。 行和列都从0开始编制索引,因此第一行和第一列都通过传递0表示。 所有字段都必须占据唯一位置
如果目标字段也是字段集,则其在位置数组中的记录也应包含名为fieldList的参数,即包含相同columnNumber、rowNumber和fieldName成员的对象数组。 对于字段集在父列表中的位置,它本身被视为单个字段,而它的子字段根据fieldList参数中的给定位置进行定位。
POST /rest/asset/v1/form/{id}/reArrange.json
Content-Type: application/x-www-form-urlencoded
positions=[{"columnNumber":0,"rowNumber":0,"fieldName":"FirstName"},{"columnNumber":0,"rowNumber":1,"fieldName":"LastName"}, {"columnNumber":0,"rowNumber":2, "fieldName":"Email"}]
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "bb18#15508ef9c04",
"result": [
{
"id": 764
}
]
}
富文本
富文本字段是通过添加的。 字段内容以multipart/form-data形式传递。 它应结构化为不包含任何脚本、元标记或链接标记的HTML内容。
POST /rest/asset/v1/form/{id}/richText.json
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="text"
Content-Type: text/html
<div>Fancy Rich Text Component</div>
-----------------------------9051914041544843365972754266--
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "82c8#154f423bf5c",
"result": [
{
"id": "SHRtbFRleHRfMjAxNi0wNS0yN1QxNDozNDoyNC4xMTVa",
"labelWidth": 260,
"dataType": "htmltext",
"rowNumber": 8,
"columnNumber": 0,
"visibilityRules": {
"ruleType": "alwaysShow"
},
"text": "<div>Fancy Rich Text Component</div>"
}
]
}
字段集
Marketo forms具有称为字段集的可选组件。 字段集是被视为顶级字段列表中的单个字段的字段组,用于按照可见性规则移动和处理字段。 例如,如果存在符合性要求字段,并且客户端选择“是”,则它可能会显示包含HIPAA和PCI符合性要求字段的字段集。
字段集中的字段在整个表单中是唯一的,因此重复字段可能不在表单的父字段列表和子字段集中。 字段集是通过端点添加的,然后将显示在的字段的结果中。 通过通过将字段移动到字段集的fieldList中,可向字段集添加字段。 对于这些端点,数据以x-www-form-urlencodedPOST传递,而不是以JSON格式传递。
可见性规则
每个字段可以具有一组可见性规则,这些规则根据访客输入到表单中的值确定访客是否可以看到该字段。 规则对表单中存在的subjectField的值与规则中给定的值列表进行比较。 每个字段可以具有一个类型的可见性规则,即显示、隐藏或alwaysShow,然后列出要评估的规则。 规则的评估方式为从上到下,第一个评估为true的规则是将应用的规则。
更改可见性规则是一种破坏性更新。
POST /rest/asset/v1/form/{id}/field/Email/visibility.json
Content-Type: application/x-www-form-urlencoded
visibilityRule={"ruleType":"show", "rules":[{"subjectField": "LastName", "operator": "isNotEmpty", "values": [], "altLabel": "Email:"}]}
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "ab4a#15509030601",
"result": [
{
"formFieldId": "Email",
"ruleType": "show",
"rules": [
{
"subjectField": "LastName",
"operator": "isNotEmpty",
"values": [],
"altLabel": "Email:"
}
]
}
]
}
有关可用运算符的完整列表,请参阅的端点引用页面。
跟进
Marketo表单可能有动态的跟进页面行为,其中在提交时可能会根据指定字段的内容应用要重定向到给定页面或停留在当前页面的规则。 规则可以交替称为“感谢页面”规则或“跟进页面”规则。 这些规则表示为成员followupType
、followupValue
、operator
、subjectField
、values
和default
的闯厂翱狈数组。 default
是一个Boolean值,数组中只有一个记录可能为true。 当访客没有其他规则资格时,将使用指定为默认值的规则。 followupType
可以是濒辫或耻谤濒,其中濒辫表示followupValue
的Marketo登录页面ID,而url表示指向其他页面的URL。 运算符用于比较主题字段的值与提供的值列表。
提交按钮
表单的提交按钮样式使用端点进行管理。 可以修改buttonPosition、buttonStyle、label和waitingLabel(提交待处理时显示的标签)。
这是破坏性更新。
审批
与大多数其他资产一样,表单遵循草稿批准的模型,其中可以存在草稿版本和/或批准的版本。 只要将更新应用于表单,就会始终先将更新应用于草稿版本,并且仅在表单获得批准后才可实时查看。 批准表单时采用当前草稿版本,并将批准的版本(如果有)替换为草稿。 如果表单必须从实时中删除,则必须先取消批准,这将删除任何当前草稿,并将批准的版本降级为仅草稿状态。 在尝试删除之前,Forms应始终不被批准。
渐进式配置
为表单启用渐进式分析时,名为“Profiling”的字段集将包含在其字段列表中。 要在渐进式分析列表中添加或删除字段,必须使用更新字段位置终结点。 此端点进行破坏性更新,因此表单中的所有字段都必须包含在每个请求中。 以下示例将“电话”字段添加到渐进式分析列表。
POST /rest/asset/v1/form/{id}/reArrange.json
Content-Type: application/x-www-form-urlencoded
positions=[{"columnNumber":0,"rowNumber":0,"fieldName":"Email"},{"columnNumber":0,"rowNumber":1,"fieldName":"LastName"},{"columnNumber":0,"rowNumber":2,"fieldName":"Company"},{"columnNumber":0,"rowNumber":3,"fieldName":"Website"},{"columnNumber":0,"rowNumber":4,"fieldName":"Profiling","fieldList":[{"columnNumber":0,"rowNumber":0,"fieldName":"Phone"}]}]
{
"success": true,
"errors": [],
"requestId": "3d6a#164190dbdf2",
"result": [
{
"id": 1031
}
]
}