Thanks Arun.
It was the "Publish" part that I missed - although I needed to do this twice for some reason. So, script error resolved for this form.
I do have another script for Company:Information form, and applied the same logic here too ... but the end result is still a script error, albeit a slightly different one.
Error:
Script Error
One of the scripts for this record has caused an error. For more details, download the log file.
TypeError: Unable to get property 'setSrc' of undefined or null reference at Form_onload (https://<FQDN>/<instance>/%7B636712172480000112%7D/WebResources/Account_main_library.js?ver=1865024846:22:7)
Bold below are the areas of change...
Before script change:
function IFRAME_Financials_onload()
{
}
function IFRAME_WebSite_onload()
{
}
function IFRAME_Map_onload()
{
}
function Form_onload()
{
// Load yahoo finance ticker link
{
var TickerValue = crmForm.all.tickersymbol.DataValue;
var YahooURL ="uk.finance.yahoo.com/q"+ TickerValue;
if (YahooURL != null)
{
crmForm.all.IFRAME_Financials.src = YahooURL;
}
}
// Load web site URL
{
var AccountURL = crmForm.all.websiteurl.DataValue;
if (AccountURL != null)
{
crmForm.all.IFRAME_WebSite.src = AccountURL;
}
}
// Load Map URL
{
var AccountStreet1 = crmForm.all.address1_line1.DataValue;
var AccountStreet2 = crmForm.all.address1_line2.DataValue;
var AccountCity = crmForm.all.address1_city.DataValue;
var AccountState = crmForm.all.address1_stateorprovince.DataValue;
var AccountZip = crmForm.all.address1_postalcode.DataValue;
var AccountCntry = crmForm.all.address1_country.DataValue;
var MapURL = "maps.google.co.uk/maps;q=" + AccountStreet1 + " " + AccountCity +" " + AccountZip + " " + AccountCntry;
if (MapURL != null)
{
crmForm.all.IFRAME_Map.src = MapURL;
}
}
}
After script change:
function IFRAME_Financials_onload()
{
}
function IFRAME_WebSite_onload()
{
}
function IFRAME_Map_onload()
{
}
function Form_onload()
{
// Load yahoo finance ticker link
{
var TickerValue = Xrm.Page.getAttribute("tickersymbol").getValue();
var YahooURL ="uk.finance.yahoo.com/q"+ TickerValue;
if (YahooURL != null)
{
Xrm.Page.getControl('IFRAME_Financials').setSrc(YahooURL);
}
}
// Load web site URL
{
var AccountURL = Xrm.Page.getAttribute("websiteurl").getValue();
if (AccountURL != null)
{
Xrm.Page.getControl('IFRAME_WebSite').setSrc(AccountURL);
}
}
// Load Map URL
{
var AccountStreet1 = Xrm.Page.getAttribute("address1_line1").getValue();
var AccountStreet2 = Xrm.Page.getAttribute("address1_line2").getValue();
var AccountCity = Xrm.Page.getAttribute("address1_city").getValue();
var AccountState = Xrm.Page.getAttribute("address1_stateorprovince").getValue();
var AccountZip = Xrm.Page.getAttribute("address1_postalcode").getValue();
var AccountCntry = Xrm.Page.getAttribute("address1_country").getValue();
var MapURL = "maps.google.co.uk/maps;q=" + AccountStreet1 + " " + AccountCity +" " + AccountZip + " " + AccountCntry;
if (MapURL != null)
{
Xrm.Page.getControl('IFRAME_Map').setSrc(MapURL);
}
}
}
It is interesting that the script error references "setSrc" yet the same setSrc was used - without error - in the Contact:Information script. Is there something wrong code or syntax in the variables in this new JS?
Also, I ran the Dynamics 365 V9 Javascript Validator in XrmToolBox, and it is returning the following:
Method Xrm.Page must be replace with ExecutionContext.getFormContext
This is mentioned for every line in both this Account_main_library.js and Contact_main_library.js scripts ... can you advise on this?
Should I just replace the Xrm.Page references in the lines with ExecutionContext.getFormContext?
Example:
var AccountCntry = Xrm.Page.getAttribute("address1_country").getValue();
and
Xrm.Page.getControl('IFRAME_Map').setSrc(MapURL);
...become...
var AccountCntry = ExecutionContext.getFormContext.getAttribute("address1_country").getValue();
and
ExecutionContext.getFormContext.getControl('IFRAME_Map').setSrc(MapURL);
Thanks for your help.
J