I have a form connected to SharePoint. I am trying to hide a date and/or a lookup field. The code below works fine to hide text fields, but not date or lookups apparently. Please help!
function hideresponsefields() {
if (fd.field('Document_x0020_Status').value != 'Awaiting Response' && fd.field('Document_x0020_Status').value != 'Closed') {
$(fd.field('Response').$parent.$el).hide();
$(fd.field('Response_x0020_From').$parent.$el).hide();
$(fd.control('ResponseDate').$parent.$el).hide();
}
}
Hello @wbrunner,
This code should work to hide date and lookup fields.
Is that a complete code?
Do you get any errors in the console(F12)?
Its in a SPRender field
fd.spRendered(function() {
function hideresponsefields() {
if (fd.field('Document_x0020_Status').value != 'Awaiting Response' && fd.field('Document_x0020_Status').value != 'Closed') {
$(fd.field('Response').$parent.$el).hide();
$(fd.field('Response_x0020_From').$parent.$el).hide();
$(fd.control('ResponseDate').$parent.$el).hide();
}
}
hideresponsefields();
});
so that hides the response from field (text) and the response field (text).
duh. I was trying to use control instead of field since it was a date. Got it now.
1 Like
@wbrunner,
You are more attentive than me.
I did not notice this typo!