1

I'm searching to get the name of the current view of a record list. Is there a way to do it?

2
  • Xrm.Page.data.entity.getEntityName() See the Client Side API Documentation. msdn.microsoft.com/en-us/library/gg328255.aspx Commented Apr 24, 2018 at 9:50
  • Xrm.Page.data is not available in a record list (note that by "record list" I don't mean a subgrid in an entity form) Commented Apr 24, 2018 at 13:43

1 Answer 1

1

You can use the below script to get the view name from ribbon:

var viewName = '';
if (crmGrid && crmGrid.control) {
viewName = crmGrid.control.get_viewTitle();
}

Reference

Update:

I don't see a supported way to do it. But there are some unsupported solution (may be only way, I haven't tested it personally)

function HideButtonBasedOnViewSelected (selectedCtrl) {             
        var query = selectedCtrl.get_viewTitle();
        if (query == 'Your View Name') {
            return false;
        }
        else
            return true;
    }

Add Crm parameter, and set parameter value as SelectedControl
To get selected view name need to use some unsupported JavaScript.

Community thread

Sign up to request clarification or add additional context in comments.

3 Comments

crmGrid is undefined.
@Dremor based on your crm version you may need to pass primarycontrol as crm parameter in ribbon & try to consume control from formcontext
tried primaryControl earlier, result in a null object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.