web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Passing the entityType/Entity Name as a parameter to a form

(0) ShareShare
ReportReport
Posted on by 2,175

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:

pastedimage1590983728918v1.png

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);
    
}

I have the same question (0)
  • Suggested answer
    Samuel Cavichioli Profile Picture
    on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans