This is the code that I am using successfully to integrate the SharePoint Document Grid in an iframe. I do have sharepoint server based integration enabled between CRM and SP. I did add the SP url into the iframe property, and did add some additional code to hide this iframe from the mobile application.
JS Code:
function SetDocumentFrame() {
var isCrmForMobile = (Xrm.Page.context.client.getClient() == "Mobile")
if (isCrmForMobile) {
// Code for CRM for phones and tablets only goes here.
}
else {
// Code for web browser or CRM for Outlook only goes here.
//Get Record ID through JavaScript
var recordId = Xrm.Page.data.entity.getId().replace("{", "").replace("}", "");
//Then get the entity type code,
var oTypeCode = Xrm.Page.context.getQueryStringParameters().etc; //Entity Type code. Eg. for lead it is 4
//Then get the current form id,
var CurrentFormId = Xrm.Page.ui.formSelector.getCurrentItem().getId().replace("{", "").replace("}", "");
//Now get the control of the iframe and set the src for the sharepoint document view,
Xrm.Page.getControl("IFRAME_SharePoint").setSrc(Xrm.Page.context.getClientUrl() + "/userdefined/areas.aspx?formid=" + CurrentFormId + "&inlineEdit=1&navItemName=Documents&oId=%7b" +
recordId + "%7d&oType=" + oTypeCode + "&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White");
}
}
One important caveat is that this frame will not load with the document location until the record is created. Because of this, I have the following JS as well:
//hide the sharepoint tab until record creation
function hideSharePoint() {
var isCrmForMobile = (Xrm.Page.context.client.getClient() == "Mobile")
if (isCrmForMobile) {
// Code for CRM for phones and tablets only goes here.
}
else {
// Code for web browser or CRM for Outlook only goes here.
var formType = Xrm.Page.ui.getFormType();
if (formType === 1) {
window.parent.Xrm.Page.ui.tabs.get('tab_2').setVisible(false);
}
else {
window.parent.Xrm.Page.ui.tabs.get('tab_2').setVisible(true);
}
}
}