javascriptnode.jssalesforcesalesforce-lightningjsforce

How to use html tag in salesforce task api?


I am using JSForce for make api calls on salesforce. I am trying to add task using this 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);
  })

It is working as expected except the body(Description) part contains some html tags so it does not parse it instead paste as it is in the comment section. Kindly help.


Solution

  • The backend probably escapes the html characters when the comment gets uploaded as a security measure; either before it gets stored in the database or before it gets returned to the client.
    This should logically be done to disallow users to upload malicious tags and is standard.

    Instead of uploading html tags, I would suggest uploading markdown tags in the body(description) instead on which you can find info here.

    Then you need a script to convert the markdown back to html before rendering it.