Last active
August 29, 2015 14:24
-
-
Save mktange/03dbbdff0a6b45c30731 to your computer and use it in GitHub Desktop.
Use in developer console while on the desired CRM form page. Extracts all visible control labels from a Dynamics CRM form, and saves it as a .csv file. Useful for creating a template for data import based on a CRM form.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: | |
function getFrame() { | |
var e = $('#crmContentPanel iframe:not([style*="visibility: hidden"])'); | |
return e.length > 0 && e[0].contentWindow.Xrm.Page.ui ? e[0].contentWindow : null | |
} | |
function download(e, t) { | |
var n = document.createElement("a"); | |
if (n.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(t)), n.setAttribute("download", e), document.createEvent) { | |
var a = document.createEvent("MouseEvents"); | |
a.initEvent("click", !0, !0), n.dispatchEvent(a) | |
} else n.click() | |
} | |
var frame = getFrame(); | |
if (null == frame) alert("Please make sure you are on an entity form and try again."); | |
else { | |
var controls = []; | |
frame.Xrm.Page.ui.controls.forEach(function(e) { | |
if (e.getParent() && e.getControlType() != "subgrid" && e.getLabel()) controls.push(e.getLabel()) | |
}), download("controls.csv", controls.join()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment