I have a button on case entity to create a new task, i want to populate case title in the regarding field of task when a new task is created using the button. Any ideas if we can achieve this through java script.
I tried the below code but it doesn't seem to work, i have implemented the same for other entities and it works fine but in this case where i have to populate data in the regarding field doesn't work
function openTask() {
var parentcaselookup = Xrm.Page.getAttribute("parentcaseid");
if (parentcaselookup != null) {
var parameters = {};
var parentcaselookupObjValue = parentcaselookupObj.getValue();
parentcaselookupEntityType_ = parentcaselookupObjValue[0].entityType, //To get EntityName
parentcaselookupRecordGuid_ = parentcaselookupObjValue[0].id, // To get record GUID
parentcaselookupRecordName_ = parentcaselookupObjValue[0].name;
var childcaseName = Xrm.Page.getAttribute("title").getValue(); // To fetch case name
parameters["regardingobjectid"] = parentcaselookupRecordGuid;
parameters["regardingobjectidname"] = parentcaselookupRecordName;
Xrm.Utility.openEntityForm("task", null, parameters);
}
}