Seems like your variable parent is null, or parent.Xrm.Page.ui.controls.get('Select_Address') are null.
You can debug your code (F12 Debugger) to check your values, or post your full code, to give more information to us.
//get Grid Data
var grid =parent.Xrm.Page.getControl("Select_Address");
//get Selected rows
var selectedRows = grid.getGrid().getSelectedRows();
//get selected Row Count
var selectedRowsCount = selectedRows.getLength();
if (selectedRowsCount !=0)
//hide update button and grid control
document.getElementById("billToUpdateButton").style.visibility = "hidden";
parent.Xrm.Page.ui.controls.get('Select_Address').setVisible(false);
parent.Xrm.Page.ui.tabs.get("general").sections.get("general_section_5").setVisible(false);
var rowData = selectedRows.get(0).getData();
var entity = rowData.getEntity();
var attributes = entity.getAttributes();
//fetch sub grid attribute values to variables
var name = attributes.get("name").getValue();
var line1 = attributes.get("line1").getValue();
var city = attributes.get("city").getValue();
var stateorprovince = attributes.get("stateorprovince").getValue();
var postalcode = attributes.get("postalcode").getValue();
var data= name + "\n" + line1 + "\n" + city + "," + stateorprovince + " " +postalcode ;
parent.Xrm.Page.getAttribute("address1_name").setValue(name);
parent.Xrm.Page.getAttribute("address1_line1").setValue(line1);
parent.Xrm.Page.getAttribute("address1_city").setValue(city);
parent.Xrm.Page.getAttribute("address1_stateorprovince").setValue(stateorprovince);
parent.Xrm.Page.getAttribute("address1_postalcode").setValue(postalcode);
/* if (name == null || name == undefined)
parent.Xrm.Page.getAttribute("new_address1info").setValue("--");
parent.Xrm.Page.ui.controls.get('Select_Address').setVisible(false);
parent.Xrm.Page.ui.tabs.get("general").sections.get("general_section_5").setVisible(false);
return;
parent.Xrm.Page.getAttribute("new_address1info").setValue(data);
parent.Xrm.Page.getAttribute("new_address1info").setSubmitMode("always");
alert("No rows selected");
this is the full code and the "Select_Address" is Address grid and it is not null. I have debugged already.
either parent.Xrm.Page.ui.controls.get('Select_Address') or parent.Xrm.Page.ui.tabs.get("general").sections.get("general_section_5") is null.
better introduce an if loop before applying setvisible
like if(parent.Xrm.Page.ui.tabs.get("general").sections.get("general_section_5") !=null)
Also please change all selectors to small case.
Hey There,
I ran into the same issue as you did! It was very confusing because I could call methods from the namespace Xrm.Page.Ui.* from the browser console but not from the specific JS code I wanted to use it in.
In my specific scenario... I was trying to call this from an async method. What happened is when that async code was executed it didn't know about Xrm.Page (page == undefined from this async context). As a result, the code would crash with an error "Cannot read property of blah" but I could read it from the console without issue.
Try moving your XRM.Page.* calls to outside of any async code, store these values and pass them to the method you need them in.
Hope this helps (someone)
Try using window.parent.Xrm.Page.ui.controls.get('Select_Address');
Also if you are opening html webresource in a popup you may need to get Xrm using : window.top.opener.Xrm.Page.ui.controls.get('Select_Address');
Hope this helps:)
Right,
Seems like your variable parent is null, or parent.Xrm.Page.ui.controls.get('Select_Address') are null.
You can debug your code (F12 Debugger) to check your values, or post your full code, to give more information to us.
Best Regards,
either parent.Xrm.Page.ui.controls.get('Select_Address') or parent.Xrm.Page.ui.tabs.get("general").sections.get("general_section_5") is null.
better introduce an if loop before applying setvisible
like if(parent.Xrm.Page.ui.tabs.get("general").sections.get("general_section_5") !=null)
Also please change all selectors to small case.
Try using window.parent.Xrm.Page.ui.controls.get('Select_Address');
Also if you are opening html webresource in a popup you may need to get Xrm using : window.top.opener.Xrm.Page.ui.controls.get('Select_Address');
Hope this helps:)