
Hi,
I'm trying to pass 3 parameters from a JS script when I press a ribbon button.
I've created 3 parameters on the form as per the below screenshot:
For the entity_name parameter I selected type of "EntityType", case_id is "UniqueId" and case_name is "SafeString".
I passed the parameters and console logged everything and the ID and name logs fine but the entity type seems to throw a script error without telling me what the error is.
So the script which is calling the navigateto method and passing the parameters through:
function openDialogue(executionContext) {
var formContext = executionContext.getFormContext();
var caseName = formContext.getAttribute("title").getValue();
var param = {
case_id:formContext.data.entity.getId().slice(1, -1),
entity_name: "incident",
case_name: caseName
};
var pageInput = {
pageType: "entityrecord",
entityName: "task",
formId: "cba9b356-6a70-4513-826f-f6b0bd3hf21c",
data: param
};
var navigationOptions = {
target: 2,
height: {value: 80, unit:"%"},
width: {value: 70, unit:"%"},
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success(result) {
console.log("Record created with ID: " result.savedEntityReference[0].id
" Name: " result.savedEntityReference[0].name)
// Handle dialog closed
},
function error() {
// Handle errors
}
);
}
and the script which console logs the value. It's from a ribbon button. As I said the other 2 parameters seem to log fine but the entityType/ name doesn't seem to log:
function logConsole(primaryControl) {
var formContext = primaryControl;
var caseIdPassed = formContext.data.attributes.get("case_id").getValue().slice(1,-1);
var caseName = formContext.data.attributes.get("case_name").getValue();
var caseEntityName = formContext.data.attributes.get("entity_name").getValue();
console.log(caseEntityName);
} Hi,
I recommend that you define your Javascript function with the PrimaryEntityTypeName variable as argument and then in the Ribbon definition, you can pass the PrimaryEntityTypeName CRM Parameter.
Refer to the article: Pass data from a page as a parameter to Ribbon Actions.
Please, let me know if you need any additional help.