Hi,
I am trying to set up this implementation on a custom entity form following this article:
I was able to set it up successfully but not quite what I wanted. I've setup to show the document upload control like the below screenshot.
But instead, I am seeing this associated view of SharePoint Document like below:
This is the url I am using in the javascript web resource for setting iframe url.
The other thing was, I did not see any relationship between my custom document entity and SharePoint Document entity after integrated SharePoint with CRM.. which I guess creates one automatically. So I created a 1:N relationship between my custom Document entity and SharePoint Document entity manually.
What am I doing wrong and why am I not seeing the iframe to upload documents like the first screenshot?
Please guide me through this. Thanks for any help.
*This post is locked for comments
I found the supported way this can be done for the UCI... for online anyway.
It can only be done through the make.powerapps.com website. (hens only online, as far as i know)
Login with a user from your CRM online enviroment, in the top right under enviroment select the CRM instance you want to edit.
The on the right open 'solutions', then open the solution you want to added, navigate to the forum you want (search is in the top right).
in the tree view (on the left), find the location you want to add the grid to.
Then you can hit 'add component', add a subgrid, tick 'show related records' add and then find something like 'documents (regarding)' (atleast i think that's what it would be in english)
save and publish (top right)
If you now look at this grid in the old form editor much is grayed out (so it really isn't supported there), But you can make it take up more lines which is something i couldn't find how to do in make.powerapps.com.
How do I get the Object type code out of a custom entity?
I've tried using the ways suggested above, and the new methods to replace the depreciated methods.
However it appears that either I can't retrieve this using those methods or my custom entity doesn't provide me with the object type code.
Thanks
Lee
To solve this in UCI - follow this thread - www.crmug.com/.../viewthread
Btw, this is unsupported approach - so we have to continuously monitor & fix whenever breaks :)
Read my answer in Stack Overflow: stackoverflow.com/.../7920473
Did you get it working on 9.0 UCI?.
Hi
I got all to work so I have all the menu buttons which are also working and are refering to the correct SPdocuemntsite (if I click on "Open Sharepoint" I get to the correct site) BUT... I am not able to see the actual documents in the list. I suspect it has something to do with settings on Sharepoint for the site but haven´t been able to figure it out. Any ideas?
This solution works on the classic interface. However it does not work on the new unified UI interface. Could you please suggest how this could work with unified app UI(v9.x) ?
Set to fire on load. We have since moved away from the mobile application, so my code has changed. I did check it now, and I am not seeing the SP grid on the mobile app. You may want to try the following:
function SetDocumentFrame() {
//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");
}
//hide the sharepoint tab until record creation
function hideSharePoint() {
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);
}
}
Hey Mohamed,
We have the documents section working, but I'm having trouble hiding it from mobile. I've used the mobile code to hide other things but it isn't working in this case. Do you have the documents web resource firing on load or tab change?
Thanks,
Greg
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);
}
}
}
This script has worked for me in Dynamics 365 v8.2:
function showInlineDocuments(context, iframeName) {
const formType = context.getFormContext().ui.getFormType();
switch (formType) {
case 2://Update
setIframeSrc(context, iframeName);
toggleIframeVisibility(context, iframeName, true);
break;
default:
toggleIframeVisibility(context, iframeName, false);
return;
}
}
function toggleIframeVisibility(context, iframeName, visible) {
context.getFormContext().getControl(iframeName).setVisible(visible);
}
function setIframeSrc(context, iframeName) {
const src = getIframeSrc(context);
const iframe = context.getFormContext().getControl(iframeName);
iframe.setSrc(src);
}
function getIframeSrc(context) {
const formContext = context.getFormContext();
const entityId = formContext.data.entity.getId().replace('{', '').replace('}', '');
const etc = formContext.context.getQueryStringParameters().etc;
const form = formContext.ui.formSelector.getCurrentItem() || formContext.ui.formSelector.items.get(0);
const formId = form.getId().replace('{', '').replace('}', '');
const src = formContext.context.getClientUrl() + '/userdefined/areas.aspx?formid=' + formId + '&inlineEdit=1&navItemName=Documents&oId=%7b' + entityId + '%7d&oType=' + etc
+ '&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White';
return src;
}
To use it, call the showInlineDocuments function either when the form loads or when the appropriate tab is expanded. Make sure the 'pass execution context' option is selected in your event and include the control name as the iframeName parameter (e.g. 'IFRAME_documentsframe'). It's been tested in IE and chrome. I used the recommended settings and got the basic code here:
https://jlattimer.blogspot.com/2017/01/show-sharepoint-documents-on-main-form.html
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156