如何在 salesforce 任务 api 中使用 html 标签?

How to use html tag in salesforce task api?

我正在使用 JSForce 对 salesforce 进行 api 调用。我正在尝试使用此 api

添加任务
const body = `<a href=${process.env.CONSOLE_URL}/myUrl/${id}>Click Here</>`
 const createObj = {
      WhoId: contact.Id,
      Subject: 'Call',
      CallDisposition : 'Call',
      Description : body
    };
 this.conn.sobject("Task").create(createObj, function(err, result) {
    if (err) return reject(err);
    return resolve(result);
  })

body(Description) 部分包含一些 html 标记外,它按预期工作,因此它不会解析它,而是按原样粘贴在评论部分。请帮忙。

作为安全措施,当评论上传时,后端可能会转义 html 字符;在将其存储在数据库中之前或在将其返回给客户端之前。
这在逻辑上应该是为了禁止用户上传恶意标签并且是标准的。

与其上传 html 标签,我建议在 body(description) 中上传 markdown 标签,您可以在其中找到信息 here.

然后你需要一个脚本在渲染之前将 markdown 转换回 html。

Description 是一个纯文本字段,因此它不会解析 HTML。一般来说,解决方案是向您的对象添加一个正确类型的自定义字段并填充该字段。允许 HTML and/or 其他标记的字段类型是 Text Area (Rich):

Text Area (Rich)

[...] users can format the field content and add images and hyperlinks. [...] The maximum field size is 131,072 characters, inclusive of all the formatting and HTML tags.

不幸的是,活动(任务是 Activity 的一种类型)不允许文本区域(丰富)类型的自定义字段。可用于活动自定义字段的另一种字段类型是 URL:

Allows users to enter up to 255 characters of any valid website address. Only the first 50 characters are displayed on the record detail pages. When a user clicks the field in Salesforce Classic, the URL opens in a separate browser window. In Lightning Experience, internal URLs open in the same window and external URLs open in a separate browser window. In Salesforce console apps, the URL opens in a new workspace tab. In Lightning console apps, internal URLs open in a new workspace tab and external URLs open in a separate browser window.

您可以在描述字段中使用纯文本,而不是在一个字段中使用 HTML 标记,并说明单击包含在自定义 URL 类型字段中的 link。