Reputation: 31237
In our Dynamics 365 instance, we're trying to open a quick create form for an entity called SourceAssessment
using the code example here
var thisEntity = {
entityType: "SourceAssessment",
id: Xrm.Page.data.entity.getId()
};
var callback = function (obj) {
console.log("Created new " + obj.savedEntityReference.entityType + " named '" +
obj.savedEntityReference.name + "' with id:" + obj.savedEntityReference.id);
}
var setName = { name: "Child account of " + Xrm.Page.getAttribute("name").getValue()
};
Xrm.Utility.openQuickCreate("SourceAssessment", thisEntity, setName).then(callback, function
(error) {
console.log(error.message);
});
Xrm.Page.data.entity.getId()
throws
Uncaught TypeError: Cannot read property 'entity' of null(…)
Xrm.Page.getAttribute("name").getValue()
throws
Uncaught TypeError: Cannot read property 'getValue' of null(…)
Xrm.Utility.openQuickCreate("SourceAssessment", thisEntity, setName).then(callback, function (error) {
console.log(error.message);
});
throwsThe entityLogicalName isn't valid. This value can't be null or empty, and it must represent an entity in the organization.
Upvotes: 1
Views: 1196
Reputation: 417
When using the developer console to execute code, you have to first switch to the correct frame, in order to access the Xrm.Page
object of the form.
In Chrome you can switch frames here:
The frame you want to be in is usually called customScriptsFrame, and other times it is one of the numbered contentIFrames.
Upvotes: 2