Dynamic 365 CRM openEntityForm or windows.open with html as parameter

帅比萌擦擦* 提交于 2019-12-11 15:46:39

问题


I have email template which I 'parse' and send (from current Lead form) as a parameter to new email form (from JavaScript).

var parameters = {};
parameters["subject"] = 'Subject name';
parameters["description"] = '<font face="Tahoma, Verdana, Arial" size=2 style="display:inline;"><br></font>';

Xrm.Utility.openEntityForm("email", null, parameters);

or

let serverUrl = "https://companyname.crm4.dynamics.com";

let extraqs = "subject=Subject name";
extraqs += '&description=<font face="Tahoma, Verdana, Arial" size=2 style="display:inline;"><br></font>';

let targetUrl = serverUrl.replace(/\/$/, "") + "/main.aspx?etn=email&pagetype=entityrecord&extraqs=" + encodeURIComponent(extraqs);
parent.open(targetUrl);

or

let serverUrl = "https://companyname.crm4.dynamics.com";

let extraqs = 'subject=' + encodeURIComponent('Subject name');
extraqs += '&description=' + encodeURIComponent('<font face="Tahoma, Verdana, Arial" size=2 style="display:inline;"><br></font>');

let targetUrl = serverUrl.replace(/\/$/, "") + "/main.aspx?etn=email&pagetype=entityrecord&extraqs=" + extraqs;
parent.open(targetUrl);

I get error every time I want to send anything look like as html tag (anything contains '<' or '>' sign).

Is it possible at all, to send my html markup trough the parameters, is there any security issue with this ?


回答1:


This is solvable with encodeURIComponent / decodeURIComponent like this:

parameters["description"] = encodeURIComponent('<html here>');

And on the other side:

var description = decodeURIComponent(incomingParameterHere);

In this fashion your HTML passes through as a simple string. This can(should?) be applied to all strings being passed around via JS.




回答2:


What I found what that for description to contain html tags it needs the pId and pType values defined (wonder if this is by design or a bug)

var entityFormOptions = {
    entityName: "email"
};

var emailFormParams = {
    subject: "subject",
    description:"<p1>html here</p1>",
    //sets the regarding - needed for description to be html
    pId:"{GUID}",
    pType:112 //objectTypeCode for the party
};

Xrm.Navigation.openForm(entityFormOptions, emailFormParams);


来源:https://stackoverflow.com/questions/47416197/dynamic-365-crm-openentityform-or-windows-open-with-html-as-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!