Пара вещей здесь. Вам нужно будет исправить идентификатор перед добавлением его в массив параметров:
parameters["parameter_regardingid"] = Regarding[0].id.replace(/[{}#]/g, "");
Кроме того, если вы называете ваш параметр атрибуты идентичны именам полей на вашей целевой форме, вы не будете иметь, чтобы переместить их в отдельный шаг в вашем событии загрузки .:
parameters["new_fieldnameonTARGETform"] = Xrm.Page.getAttribute("new_fieldnameonTHISform").getValue();
Вот несколько методов, которые я использую помощь в построении массива параметров до вызова Xrm.Utility.openEntityForm. Я добавляю их как расширения к вездесущему Xrm Service Toolkit, но вы можете поместить их в свою собственную общую библиотеку lib. Используется.
toolkit.AddParameter = function (parameters, attributeName, targetAttributeName) {
/// <summary>
/// Form and add a parameter to the parameters array. Used with Xrm.Utility.openEntityForm.
/// Example: XrmServiceToolkit.Common.addParameter(parameters, "new_firstname");
/// <param name="parameters" type="array">
/// The parameter object array, i.e. var parameters = {};
/// </param>
/// <param name="attributeName" type="string">
/// The name of the field on the source form.
/// </param>
/// <param name="targetAttributeName" type="string" optional="true">
/// The name of the field on the target form; not required of the source and target
/// field names are identical.
/// </param>
/// </summary>
var attribute = Xrm.Page.getAttribute(attributeName);
if (!toolkit.IsNullOrEmpty(attribute)) {
if (!toolkit.IsNullOrEmpty(attribute.getValue())) {
parameters[(arguments.length == 3 ? targetAttributeName : attributeName)] = attribute.getValue();
}
}
};
toolkit.AddDateParameter = function (parameters, attributeName, targetAttributeName)
{
/// <summary>
/// Form and add a date parameter to the parameters array. Used with Xrm.Utility.openEntityForm.
/// Example: XrmServiceToolkit.Common.addDateParameter(parameters, "new_birthdate", "new_dateofbirth");
/// <param name="parameters" type="array">
/// The parameter object array, i.e. var parameters = {};
/// </param>
/// <param name="attributeName" type="string">
/// The name of the field on the source form.
/// </param>
/// <param name="targetAttributeName" type="string" optional="true">
/// The name of the field on the target form; not required of the source and target
/// field names are identical.
/// </param>
/// </summary>
var attribute = Xrm.Page.getAttribute(attributeName);
if (!toolkit.IsNullOrEmpty(attribute)) {
if (!toolkit.IsNullOrEmpty(attribute.getValue())) {
var dateValue = attribute.getValue();
parameters[(arguments.length == 3 ? targetAttributeName : attributeName)] = dateValue.getMonth() + '/' + dateValue.getDate() + '/' + dateValue.getFullYear();
}
}
};
toolkit.AddLookupParameter = function (parameters, attributeName, targetAttributeName) {
/// <summary>
/// Form and add a lookup parameter to the parameters array. Used with Xrm.Utility.openEntityForm.
/// Example: XrmServiceToolkit.Common.addLookupParameter(parameters, "new_consumerid");
/// <param name="parameters" type="array">
/// The parameter object array, i.e. var parameters = {};
/// </param>
/// <param name="attributeName" type="string">
/// The name of the field on the source form.
/// </param>
/// <param name="targetAttributeName" type="string" optional="true">
/// The name of the field on the target form; not required of the source and target
/// field names are identical.
/// </param>
/// </summary>
var attribute = Xrm.Page.getAttribute(attributeName);
if (!toolkit.IsNullOrEmpty(attribute)) {
if (!toolkit.IsNullOrEmpty(attribute.getValue())) {
parameters[(arguments.length == 3 ? targetAttributeName : attributeName)] = attribute.getValue()[0].id.replace(/[{}#]/g, "");
parameters[(arguments.length == 3 ? targetAttributeName : attributeName) + "name"] = attribute.getValue()[0].name;
}
}
};
Использование является:
//argument of the openEntityForm().
var parameters = {};
//add values to the parameter array.
XrmServiceToolkit.Common.AddLookupParameter(parameters, "new_opportunityid");
XrmServiceToolkit.Common.AddParameter(parameters, "new_status");
XrmServiceToolkit.Common.AddDateParameter(parameters, "new_startdate");
//open the editor page for this entity type.
Xrm.Utility.openEntityForm("new_entity", null, parameters);
Спасибо, я это написал, но его и не похоже на работу. он не дает никаких ошибок, но поле пусто. Мне кажется, что мне нужно, чтобы тема задания появлялась в этом поле поиска. Можете ли вы мне помочь? – userS