by asomat
15. October 2012 08:23
b5a3e268-46a2-41f3-8f29-3d9d8f3a8dd9|1|4.0
Tags: WRPCTokenUrl, TimeStamp, CRM 2011, CRM Web Service, Customization, Design, Discovery Service, Jabar, Jabar Alsomat, Java Script, JavaScript
Categories: CRM 5.0 | CRM Picture | Dynamics CRM | Form Picture | JavaScript | Microsoft | Webfortis
by Chuck Oldes, MCT, MCTS, MCSE
3. August 2012 08:47
One of the advantages of MS CRM 2011 is the introduction of Web Resources, which allows you to reuse JavaScript across mulitple Entities. By centralizing code that can be reused you reduce the amount of custom code that needs to be maintained and in this example you can create a function that completes the same procedure but allows for flexibility. In this example we want to centrally control the URL use by IFRAME located in different Entities. First step is to build a function that would allow for changing the URL based on variables being passed into the function.
Create a Web Resoucre JavaScript using the below code
var url1 = "http://sharepoint/sites/site1/Shared%20Documents/ ";
var url2 = “http://sharepoint/sites/site2/Shared%20Documents/";
function setIFrameSrc(IFrameName, ChangeContentURL)
{
if (!isNullOrEmptyString(IFrameName) && !isNullOrEmptyString(url) && !isNullOrEmptyString(value)) {
var iFrame = Xrm.Page.getControl(IFrameName);
if (iFrame != null && iFrame.getVisible()) {
if (typeof (ChangeContentURL) !== "undefined" && ChangeContentURL && !isNullOrEmptyString(url2)) {
url1 = url2
}
iFrame.setSrc(url 1);
}
}
}
Once you have the Script created with the function that was outlined above ensure that you load it above the Script in which you are going to invoke it.
From the OnLoad event of a entity you can invoke function with a simple call. To load url1 do not add in a ChangeContentURL value as part of invoking the function.
setIFrameSrc("IFRAME_Documents");
Changing the URL you simply have to add a value as part of invoking the function. By passing a true into the ChangeContentURL variable in the function it will step into the if statement and change to url2.
setIFrameSrc("IFRAME_Documents", true);
by Webfortis
7. May 2012 07:59
One of the advantages of MS CRM 2011 is the introduction of Web Resources, which allows you to reuse JavaScript across mulitple Entities. By centralizing code that can be reused you reduce the amount of custom code that needs to be maintained and in this example you can create a function that completes the same procedure but allows for flexibility. In this example we want to centrally control the URL use by IFRAME located in different Entities. First step is to build a function that would allow for changing the URL based on variables being passed into the function.
Create a Web Resoucre JavaScript using the below code
var url1 = "http://sharepoint/sites/site1/Shared%20Documents/ ";
var url2 = “http://sharepoint/sites/site2/Shared%20Documents/";
function setIFrameSrc(IFrameName, ChangeContentURL)
{
if (!isNullOrEmptyString(IFrameName) && !isNullOrEmptyString(url) && !isNullOrEmptyString(value)) {
var iFrame = Xrm.Page.getControl(IFrameName);
if (iFrame != null && iFrame.getVisible()) {
if (typeof (ChangeContentURL) !== "undefined" && ChangeContentURL && !isNullOrEmptyString(url2)) {
url1 = url2
}
iFrame.setSrc(url 1);
}
}
}
Once you have the Script created with the function that was outlined above ensure that you load it above the Script in which you are going to invoke it.
From the OnLoad event of a entity you can invoke function with a simple call. To load url1 do not add in a ChangeContentURL value as part of invoking the function.
setIFrameSrc("IFRAME_Documents");
Changing the URL you simply have to add a value as part of invoking the function. By passing a true into the ChangeContentURL variable in the function it will step into the if statement and change to url2.
setIFrameSrc("IFRAME_Documents", true);