Business question:
Have an InfoPath form that on one tab allows submitter to select zero to more impacted IT applications, and on another tab (for other business role) display this selection readonly.InfoPath / IT answer:
- Have multiple Views in the InfoPath form / template;
- On the 'input' View, include a Multiple Selection List (MultiSelectList) control, and bind to the MultiLookup List Column (or ContentType Field);
- On the 'display' View, visualize the current value of MultiLookup via a Repeating Table control. Via InfoPath configuration (control properties) remove the option for user to include new entries in the table:
This part takes care of displaying [only] the selected value(s);
- What then remains is to make the control readonly, to prevent that the MultiLookup value can be changed on this tab. InfoPath does not itself support to disable the Repeating Table control. However, you can achieve this for InfoPath Forms Services context via (the power of) javascript: include on 'editifs.aspx' page script with a method that sets the html control to disabled. A complexity here is that IFS loads the form asynchronously after the surrounding page is loaded in browser, and that no event is triggered to notify the form is loaded. To handle that, I've programmed a polling approach that recurring checks whether the resulting HTML table is now present in DOM, and then disable it:
var InfoPathCheck;
var maxNrChecks = 10;
$(document).ready(function(){
InfoPathCheck = setInterval(function() { //Wait for InfoPath to finish loading
HasInfoPathLoaded();
}, 200);
});
function HasInfoPathLoaded() {
var selectAppl = $("#ctl00_m_g_d1ea83c5_3306_41e4_8419_01cfcf73921e_FormControl0_V1_I1_R5");
if (selectAppl.length > 0 || --maxNrChecks === 0) {
clearInterval(InfoPathCheck);
if (selectAppl.length > 0) {
$(selectAppl).prop('disabled', 'disabled');
}
}
}
No comments:
Post a Comment