I have a form that pulls a picture when a choice is selected. It stopped working the error is can’t read null property. Can you help, please I assume I need to put a ready somewhere but I am not sure where?
localStorage.clear();
fd.spRendered(function() {
function filterLookup(v){
// getting the selected Category (0 if nothing is selected).
var siteId = 0;
if (v) {
siteId = isNaN(v) ? v.LookupId : v;
}
if (siteId) {
// setting filtration
fd.field('Doors').filter = 'Site/Id eq ' + siteId;
} else {
// resetting the filtration
fd.field('Doors').filter = null;
}
fd.field('Doors').widget.dataSource.read();
}
function pictureChange(){
var value = fd.field('Site').$el.innerText.trim();
if(value == 'PRS'){
fd.control('Image0').source = 'https://site.sharepoint.com/devPlay/DoorsMaps/PRS.PNG';
} else if(value == 'PRI'){
fd.control('Image0').source = 'https://site.sharepoint.com/devPlay/DoorsMaps/PRI.PNG';
} else if(value == 'PTG'){
fd.control('Image0').source = 'https://site.sharepoint.com/devPlay/DoorsMaps/PTG.PNG';
} else if(value == 'PEC'){
fd.control('Image0').source = 'https://site.sharepoint.com/devPlay/DoorsMaps/PEC.PNG';
} else if(value == 'Parts'){
fd.control('Image0').source = 'https://site.sharepoint.com/devPlay/DoorsMaps/Parts.PNG';
}
}
//filter Products when form opens
filterLookup(fd.field('Site').value);
//filter Products when Category changes
fd.field('Site').$on('change', function(value){
filterLookup(value);
fd.field('Doors').value = null;
pictureChange();
value=fd.field('Site').$el.innerText;
});
function hideOrShowDueDate() {
var access= fd.field('AccessType').value;
if (fd.field('AccessType').value =='Temporary') {
// Show the Due Date field
$('.grid-to-hide').show();
} else {
// Hide the Due Date field
$('.grid-to-hide').hide();
}
}
// Calling hideOrShowDueDate when the user changes the Start Date
fd.field('AccessType').$on('change',hideOrShowDueDate);
// Calling hideOrShowDueDate on form loading
hideOrShowDueDate();
$('.hide').hide();
});
fd.spSaved(function(result) {
//simply replace this URL with yours:
result.RedirectUrl =
"https://site.sharepoint.com/";
});
Thank you